aspose.cells java匯出pdf 所有列列印在一頁上

liliyou發表於2024-12-04



import com.aspose.cells.PdfSaveOptions;
//import com.aspose.pdf.PdfSaveOptions;
import lombok.val;

import java.io.InputStream;

public class PdfHelper {

    public static void ConvertXlsxToPdf(String sourceFileName,String targetFileName,String targetFileDir) throws Exception {
        com.aspose.cells.Workbook workbook = new com.aspose.cells.Workbook("../upload/saverPdfFileDir/"+sourceFileName);
        com.aspose.cells.License license = new com.aspose.cells.License();
        InputStream is = PdfHelper.class.getClassLoader().getResourceAsStream("Aspose.license.lic");
        license.setLicense(is);
        PdfSaveOptions opts = new PdfSaveOptions();
        opts.setAllColumnsInOnePagePerSheet(true);
        val p = "../upload/saverPdfFileDir/"+targetFileName;
        workbook.save(p,opts);
    }
}

相關文章