Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JSpreadsheet
>
Tutorial
> Name a Range
The following example shows you how to name a range.
import com.independentsoft.office.spreadsheet.DefinedName; import com.independentsoft.office.spreadsheet.Workbook; import com.independentsoft.office.spreadsheet.Worksheet; public class Example { public static void main(String[] args) { try { Worksheet sheet1 = new Worksheet(); sheet1.setID(1); sheet1.setName("TestSheet1"); DefinedName range1 = new DefinedName("myrange1"); range1.setBody("TestSheet1!$A$1:$A$10"); DefinedName range2 = new DefinedName("myrange2"); range2.setBody("TestSheet1!$B$1:$D$1"); Workbook book = new Workbook(); book.getSheets().add(sheet1); book.getDefinedNames().add(range1); book.getDefinedNames().add(range2); 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*