将 Excel 转为 PDF 时渲染实线格线
Contents
[
Hide
]
为了兼容旧版本,Aspose.Cells在将Excel转换为PDF时默认将网格线渲染为点线。然而,现代Excel中网格线已渲染为实线。
通过选项 PdfSaveOptions.GridlineTypes,Aspose.Cells也可以将网格线渲染为实线。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// Create an empty Workbook | |
Workbook wb = new Workbook(); | |
//Prepare data | |
wb.getWorksheets().get(0).getCells().get("D9").putValue("gridline"); | |
//Enable to print gridline | |
wb.getWorksheets().get(0).getPageSetup().setPrintGridlines(true); | |
//Set to render gridline as solid line | |
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); | |
pdfSaveOptions.setGridlineType(GridlineType.HAIR); | |
// Save the pdf file with PdfSaveOptions | |
wb.save("output.pdf", pdfSaveOptions); |