PdfFocusToExcel(String) Method |
Saves all pages of the PDF document to Excel file
Namespace: SautinSoftAssembly: SautinSoft.PdfFocus (in SautinSoft.PdfFocus.dll) Version: 2024.12.2
Syntax public int ToExcel(
string fileName
)
Public Function ToExcel (
fileName As String
) As Integer
Parameters
- fileName String
- Path to the Excel file
Return Value
Int32
0 - saving successfully
2 - can't create output file, check the output path
3 - saving failed, email to
support@sautinsoft.comExample How to convert PDF file to Excel file using C#
using System;
using System.IO;
namespace Sample
{
class Sample
{
static void Main(string[] args)
{
string pathToPdf = Path.GetFullPath(@"..\..\..\Table.pdf");
string pathToExcel = "Result.xlsx";
SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
f.ExcelOptions.Format = SautinSoft.PdfFocus.Format.Xlsx;
f.ExcelOptions.ConvertNonTabularDataToSpreadsheet = true;
f.ExcelOptions.PreservePageLayout = true;
System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US");
ci.NumberFormat.NumberDecimalSeparator = ",";
ci.NumberFormat.NumberGroupSeparator = ".";
f.ExcelOptions.CultureInfo = ci;
f.OpenPdf(pathToPdf);
if (f.PageCount > 0)
{
int result = f.ToExcel(pathToExcel);
if (result==0)
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pathToExcel) { UseShellExecute = true });
}
}
}
}
}
How to convert PDF file to Excel file using VB.Net
Imports System.IO
Imports System.Drawing.Imaging
Imports System.Collections.Generic
Imports SautinSoft
Module Sample
Sub Main()
Dim pathToPdf As String = Path.GetFullPath("..\..\..\Table.pdf")
Dim pathToExcel As String = "Result.xlsx"
Dim f As New SautinSoft.PdfFocus()
f.ExcelOptions.Format = SautinSoft.PdfFocus.Format.Xlsx
f.ExcelOptions.ConvertNonTabularDataToSpreadsheet = True
f.ExcelOptions.PreservePageLayout = True
Dim ci As New System.Globalization.CultureInfo("en-US")
ci.NumberFormat.NumberDecimalSeparator = ","
ci.NumberFormat.NumberGroupSeparator = "."
f.ExcelOptions.CultureInfo = ci
f.OpenPdf(pathToPdf)
If f.PageCount > 0 Then
Dim result As Integer = f.ToExcel(pathToExcel)
If result=0 Then
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(pathToExcel) With {.UseShellExecute = True})
End If
End If
End Sub
End Module
See Also