Environment:windows 11 64
- Code: Select all
Imports Spire.Pdf
Imports Spire.Pdf.Conversion
Namespace ConvertPdfToExcel
Friend Class Program
Private Sub Form_Load()
Allow background operation to be cancelled
bgWorker.WorkerSupportsCancellation = True
'Allow background operation to report progress
bgWorker.WorkerReportsProgress=True
End Sub
Private Sub bgWorker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgWorker.DoWork
If bgWorker.CancellationPending Then
e.Cancel = True
Exit Sub
Else
Dim pdf As PdfDocument = New PdfDocument()
'Load the PDF document
pdf.LoadFromFile("Sample1.pdf")
'Initialize an instance of XlsxLineLayoutOptions class, in the class constructor, setting the first parameter - convertToMultipleSheet as false.
'The four parameters represent: convertToMultipleSheet, showRotatedText, splitCell, wrapText
Dim options As XlsxLineLayoutOptions = New XlsxLineLayoutOptions(False, True, True, True)
'Set PDF to XLSX convert options
pdf.ConvertOptions.SetPdfToXlsxOptions(options)
'Save the PDF document to XLSX
pdf.SaveToFile("PdfToOneExcelSheet.xlsx", FileFormat.XLSX
'Report the progress
bgWorker.ReportProgress(percent, userstate)
End if
End Sub
Private Sub bgWorker_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles bgWorker.ProgressChanged
'Report the progress of background operation here
End Sub
Private Sub bgWorker_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bgWorker.RunWorkerCompleted
If e.Cancelled Or Not IsNothing(e.Error) Then
'If the background opeartion was cancelled
'or an error occured during execution then do something
Else
'If Background execution completed normally then do something else
End If
End Sub
End Class
End Namespace