Cell getting dropped when converting Excel file to PDF

We have an Excel file that has a cell at the very bottom that does not get picked up when converting the Excel file to PDF format using Aspose.Cells for Java. I’m not clear on why that last line is getting dropped.

The test input and output files are contained in the referenced ZIP file. The test Java program is

import com.aspose.cells.SaveFormat;
import com.aspose.cells.Workbook;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;

public class AsposeCellsTest {
  public void generate(File inputFile) {
    try (InputStream licenseStream = getClass().getClassLoader().getResourceAsStream("Aspose.Cells.Java.lic")) {
      com.aspose.cells.License license = new com.aspose.cells.License();
      license.setLicense(licenseStream);

      InputStream inputStream = new FileInputStream(inputFile);
      Workbook workbook = new Workbook(inputStream);
      FileOutputStream outputStream = new FileOutputStream("output.pdf");
      workbook.save(outputStream, SaveFormat.PDF);
      inputStream.close();
      outputStream.close();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }

  public static void main(String[] args) {
    new AsposeCellsTest().generate(new File(args[0]));
  }
}

testfiles.zip (88.2 KB)

@atcollins06
Due to the printing area “B1: U70” set on worksheet “Page 1”, data outside the area will not be exported. You can refer to the following example code to clear the printing area.

InputStream inputStream = new FileInputStream(filePath + "test1.xlsx");
Workbook workbook = new Workbook(inputStream);
WorksheetCollection sheets = workbook.getWorksheets();
int sheetCount = sheets.getCount();
for (int i = 0; i < sheetCount; i++)
{
	Worksheet sheet = sheets.get(i);
	PageSetup pagesetup = sheet.getPageSetup();
	System.out.println(sheet.getName() + "   " + pagesetup.getPrintArea());
	pagesetup.setPrintArea("");
	
}
FileOutputStream outputStream = new FileOutputStream(filePath + "output_java.pdf");
workbook.save(outputStream, SaveFormat.PDF);
inputStream.close();
outputStream.close();

The output:

WR_DATA   null
Page 1   B1:U70
SOV Page 2   null

Hope helps a bit.

@John.He
Thank you for your response!! Clearing the print area does indeed fix the problem. Didn’t even know that existed in Excel.

Tony

@atcollins06
You’re welcome! If you have any other questions, feel free to ask anytime.