Skip to content

Instantly share code, notes, and snippets.

@conholdate-gists
Created January 22, 2025 19:50
Show Gist options
  • Save conholdate-gists/12689890c54a20b4b0bcdac048cd4645 to your computer and use it in GitHub Desktop.
Save conholdate-gists/12689890c54a20b4b0bcdac048cd4645 to your computer and use it in GitHub Desktop.
Convert Publisher File to Excel XLS XLSX in C#
// Initialize a MemoryStream to hold output document
MemoryStream stream = new MemoryStream();
// Load input PUB file
Aspose.Pub.IPubParser parser = Aspose.Pub.PubFactory.CreateParser("input.pub");
// Parse the input publisher file
Aspose.Pub.Document doc = parser.Parse();
// Convert the PUB file to PDF and save result in a MemoryStream
Aspose.Pub.PubFactory.CreatePdfConverter().ConvertToPdf(doc, stream);
// Load input PDF file from the MemoryStream
Aspose.Pdf.Document document = new Aspose.Pdf.Document(stream);
// Initialize ExcelSaveOptions class object
Aspose.Pdf.ExcelSaveOptions options = new ExcelSaveOptions();
// Specify the format of output Excel file
options.Format = ExcelSaveOptions.ExcelFormat.XLSX;
// Save output Excel file
document.Save("PUBToExcel.xlsx", options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment