When converting the attached excel file to a pdf (using version 18.12.0.0) there are some cells missing in the generated document (the cell content is there in MS-Excel Print Preview). The problem seems to occur only when saving a workbook to a memory stream as xlsx and then creating a new workbook from that stream and saving it to a pdf format. Below is an example of a working and a non-working method illustrating the problem. The generated pdf document contains all the data with the first method, but some cells are missing when using the second one.
public static void Working()
{
// Create from file
var workbook = new Workbook("Test.xlsx");
// Save the workbook as pdf
var pdfStream = new MemoryStream();
workbook.Save(pdfStream, SaveFormat.Pdf);
// Save to file
File.WriteAllBytes("Test.pdf", pdfStream.ToArray());
}
public static void Broken()
{
// Create from file
var workbook = new Workbook("Test.xlsx");
// Save to memory stream
var xlsxStream = new MemoryStream();
workbook.Save(xlsxStream, SaveFormat.Xlsx);
// Create from memory stream
var streamWorkbook = new Workbook(xlsxStream);
// Save the workbook as pdf
var pdfStream = new MemoryStream();
streamWorkbook.Save(pdfStream, SaveFormat.Pdf);
// Save the file
File.WriteAllBytes("Test.pdf", pdfStream.ToArray());
}
One more thing… Please try to run the following code snippet without editing the excel file first. You can open it, but if you only double click on the cells that cause the problems (without editing their content), Microsoft Excel will ask to save the file when you try to close it. If you save the file, the problem seems to go away and then both methods work just fine.
Test.zip (6.8 KB)