[]
        
(Showing Draft Content)

导出图片

GcExcel允许用户在工作表中插入图片并且支持导出到PDF文件中

将带有图片的excel文件导出为PDF格式,可以参阅以下示例代码。

// Create a new workbook and access the default worksheet
Workbook workbook = new Workbook();
IWorksheet worksheet = workbook.getWorksheets().get(0);
worksheet.getPageSetup().setOrientation(PageOrientation.Landscape);
        
FileInputStream stream = null;
try 
{
    stream = new FileInputStream("Pictures/logo.png");
} 
        
catch (FileNotFoundException e) 
{
    e.printStackTrace();
}
        
System.out.println(stream.toString());
IShape picture = null;
try 
{
   picture = worksheet.getShapes().addPicture(stream, ImageType.PNG, 20, 20, 690, 100);
} 
catch (IOException ioe) 
{
}
        
// Save to a pdf file
workbook.save("ExportPicture.pdf", SaveFileFormat.Pdf);