// Create a new workbook Workbook workbook = new Workbook(); IWorksheet ws = workbook.getWorksheets().get("Sheet1"); ws.getRange("A:A").setColumnWidthInPixel(32d); // ScrollBars can be horizontal and vertical ws.getRange("B2").setValue("A scroll bar can be horizontal or vertical."); IScrollBar scrollBar1 = ws.getControls().addScrollBar(28.3, 39, 257.4, 24.20); scrollBar1.setLargeChange(2); scrollBar1.setOrientation(FormControlOrientation.Horizontal); scrollBar1.setMax(10); scrollBar1.setMin(1); scrollBar1.setValue(3); IScrollBar scrollBar2 = ws.getControls().addScrollBar(304.7, 23.7, 26.10, 136.10); scrollBar2.setLargeChange(2); scrollBar2.setOrientation(FormControlOrientation.Vertical); scrollBar2.setMax(10); scrollBar2.setMin(1); scrollBar2.setSmallChange(1); scrollBar2.setValue(1); // Data binding ws.getRange("B7").setValue("It can be linked to a cell to bind the value."); ws.getRange("B9:C9").setValue(new Object[][] { { "Value", 4d} }); IScrollBar scrollBar3 = ws.getControls().addScrollBar(26.5, 140, 255, 21); scrollBar3.setLargeChange(2); scrollBar3.setOrientation(FormControlOrientation.Horizontal); scrollBar3.setMax(10); scrollBar3.setMin(1); scrollBar3.setSmallChange(1); scrollBar3.setLinkedCell(ws.getRange("C9")); scrollBar3.setValue(1); // Save to an excel file workbook.save("ScrollBarsBasicUsage.xlsx");
// Create a new workbook var workbook = Workbook() val ws = workbook.worksheets["Sheet1"] ws.getRange("A:A").columnWidthInPixel = 32.0 // ScrollBars can be horizontal and vertical ws.getRange("B2").value = "A scroll bar can be horizontal or vertical." val scrollBar1 = ws.controls.addScrollBar(28.3, 39.0, 257.4, 24.20) scrollBar1.largeChange = 2 scrollBar1.orientation = FormControlOrientation.Horizontal scrollBar1.max = 10 scrollBar1.min = 1 scrollBar1.value = 3 val scrollBar2 = ws.controls.addScrollBar(304.7, 23.7, 26.10, 136.10) scrollBar2.largeChange = 2 scrollBar2.orientation = FormControlOrientation.Vertical scrollBar2.max = 10 scrollBar2.min = 1 scrollBar2.smallChange = 1 scrollBar2.value = 1 // Data binding ws.getRange("B7").value = "It can be linked to a cell to bind the value." ws.getRange("B9:C9").value = arrayOf(arrayOf("Value", 4.0)) val scrollBar3 = ws.controls.addScrollBar(26.5, 140.0, 255.0, 21.0) scrollBar3.largeChange = 2 scrollBar3.orientation = FormControlOrientation.Horizontal scrollBar3.max = 10 scrollBar3.min = 1 scrollBar3.smallChange = 1 scrollBar3.linkedCell = ws.getRange("C9") scrollBar3.value = 1 // Save to an excel file workbook.save("ScrollBarsBasicUsage.xlsx")