Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JSpreadsheet
>
Tutorial
> Freeze Panes
The following example shows you how to freeze panes.
import com.independentsoft.office.spreadsheet.Cell; import com.independentsoft.office.spreadsheet.PaneState; import com.independentsoft.office.spreadsheet.PaneType; import com.independentsoft.office.spreadsheet.SheetView; import com.independentsoft.office.spreadsheet.SheetViewPane; import com.independentsoft.office.spreadsheet.Workbook; import com.independentsoft.office.spreadsheet.WorkbookView; import com.independentsoft.office.spreadsheet.Worksheet; public class Example { public static void main(String[] args) { try { Workbook book = new Workbook(); WorkbookView workbookView1 = new WorkbookView(); workbookView1.setUpperLeftCornerX(240); workbookView1.setUpperLeftCornerY(105); book.getViews().add(workbookView1); int workbookViewIndex = book.getViews().size() - 1; Worksheet sheet1 = new Worksheet(); sheet1.set("A1", new Cell("Order ID")); sheet1.set("B1", new Cell("Product")); sheet1.set("C1", new Cell("Price")); SheetViewPane pane1 = new SheetViewPane(); pane1.setState(PaneState.FROZEN); pane1.setVerticalSplitPosition(1); pane1.setActivePane(PaneType.BOTTOM_LEFT); pane1.setTopLeftVisibleCellLocation("A2"); SheetView view1 = new SheetView(); view1.setPane(pane1); view1.setIndex(workbookViewIndex); sheet1.getViews().add(view1); 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*