Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JSpreadsheet
>
Tutorial
> Set Page Size and Margins
The following example shows you how to set page size and margins.
import com.independentsoft.office.spreadsheet.Orientation; import com.independentsoft.office.spreadsheet.PageMargins; import com.independentsoft.office.spreadsheet.PaperSize; import com.independentsoft.office.spreadsheet.Workbook; import com.independentsoft.office.spreadsheet.Worksheet; public class Example { public static void main(String[] args) { try { PageMargins pageMargins = new PageMargins(); pageMargins.setLeft(1); pageMargins.setRight(1); pageMargins.setTop(0.75); pageMargins.setBottom(0.75); pageMargins.setHeader(0.3); pageMargins.setFooter(0.3); Worksheet sheet1 = new Worksheet(); sheet1.setPageMargins(pageMargins); sheet1.getPageSetupSettings().setPaperSize(PaperSize.A4_PAPER); sheet1.getPageSetupSettings().setOrientation(Orientation.PORTRAIT); Workbook book = new Workbook(); book.getSheets().add(sheet1); book.save("c:\\test\\output.xlsx", true); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*