0

I am using GemBox.Spreadsheet to create and save an Excel Spreadsheet, and convert the saved sheet to PDF.

The sample program opens and writes the Excel spreadsheet as a PDF correctly, when I run it on the saved spreadsheet. In my code I save the spreadsheet, and then try to save it as a PDF. The save throws an exception Width and Height must be non-negative.

string summaryFile = outputDirectory + "Packaging\\Cover 
    Pages\\Summary.xlsx";
{
     ExcelFile summaryExcelWorkbook = ExcelFile.Load(summaryFile);
     ExcelWorksheet summaryExcelWorksheet = summaryExcelWorkbook.Worksheets[0];
     summaryExcelWorkbook.Save(summaryFile);
 }
 try{
     ExcelFile savedSummaryFile = ExcelFile.Load(summaryFile);
     savedSummaryFile.Save( outputDirectory + "Packaging\\Cover Pages\\Summary.pdf");
 }
 catch(Exception e){
     Console.WriteLine(e.Message);
     Console.WriteLine(e.StackTrace);
 }

I expect the save to succeed, but the described exception is thrown.

  • To investigate this I will need your "Summary.xlsx" file, can you upload it? Also just as an FYI, have you tried using the latest [bug fix](https://www.gemboxsoftware.com/spreadsheet/downloads/BugFixes.htm) version? – Mario Z May 03 '19 at 06:09

1 Answers1

0

This problem was caused by setting margins outside of the paper area.