Skip to content
Guides

Convert PDF to Excel

Overview

ComPDFKit Conversion SDK supports converting PDF documents to Microsoft Excel format (.xlsx). By extracting, parsing, and importing data from PDF into Excel, users can further edit, analyze, or share Excel files. This feature helps increase productivity, reduce manual entry errors, and simplify complex document processing tasks.

Set the content options for Excel

When converting PDF files to Excel files, you need to pay attention to the settings of the following options, which will directly affect the content written to the Excel file.

  • Content options:

    If you set the ContentOptions.OnlyText option, only the text content will be written to the Excel file (without containing the table content).

OptionsDescription
ContentOptions.OnlyTextConvert text only.
ContentOptions.OnlyTableConvert table and the content in the table.
ContentOptions.AllContentConvert all content.
  • Worksheet options:
OptionsDescription
WorkSheetOptions.ForEachPageCreate one sheet for one table.
WorkSheetOptions.ForEachTableCreate one sheet for one PDF page.
WorkSheetOptions.ForTheDocumentCreate one sheet for the entire PDF document.

Sample

This sample demonstrates how to convert from a PDF to XLSX files.

kotlin
val cPDFConvert = CPDFConverterExcel(context, uri, "")

val params = CPDFConvertExcelOptions().apply {
     isContainImages = true
     isContainAnnotations = false
     excelSheetStyle = WorkSheetOptions.ForEachPage
     excelContentStyle = ContentOptions.AllContent
}

val result: ConvertError = cPDFConvert.convert(outputDir, outputFilenameNoSuffix, params, pageArrays, 
onHandle = onHandleCal, 
onProgress = onProgressCal, 
onPost = onPostCal)