Documents for Excel, Java Edition Documentation
Features / Print Settings / configure-drafts
In This Topic
    configure-drafts
    In This Topic

    GcExcel Java allows users to save drafts of the worksheets while executing the print operation.

    In order to configure drafts while printing, refer to the following example code.

    Java
    Copy Code
    // Create a new workbook and access the default worksheet
    Workbook workbook = new Workbook();
    IWorksheet sheet = workbook.getWorksheets().get(0);
    
    // Set text.
    sheet.getRange("A1:G10").setValue("Text");
    
    // Add picture in worksheet.
    FileInputStream stream = null;
    try 
    {
        stream = new FileInputStream("Pictures/logo.png");
    } 
    catch (FileNotFoundException e) 
    {
        e.printStackTrace();
    }
    try 
    {
       IShape picture = sheet.getShapes()
       .addPicture(stream,ImageType.PNG,20,20,395,60);
    } 
    catch (IOException ioe) 
    {
    }
            
    // Add header graphic.
    FileInputStream stream1 = null;
    try 
    {
        stream1 = new FileInputStream("Pictures/logo.png");
    } 
    catch (FileNotFoundException e) 
    {
        e.printStackTrace();
    }
    sheet.getPageSetup().setCenterHeader("&G");
    sheet.getPageSetup().getCenterHeaderPicture().setGraphicStream(stream1,ImageType.PNG);
    sheet.getPageSetup().getCenterHeaderPicture().setWidth(100);
    sheet.getPageSetup().getCenterHeaderPicture().setHeight(13);
    
    // Set print without graphics in page content area.
    sheet.getPageSetup().setDraft(true);
    
    // Save to a pdf file
    workbook.save("Draft.pdf", SaveFileFormat.Pdf);