OK, so reviewing the basics, each spreadsheet package has a workbook part, and some number of worksheet parts.
Using java Syntax Highlighting
SpreadsheetMLPackage
pkg = SpreadsheetMLPackage.
createPackage()
Parsed in 0.013 seconds, using
GeSHi 1.0.8.4
automatically creates the workbook part:
Using java Syntax Highlighting
public static SpreadsheetMLPackage createPackage
() throws InvalidFormatException
{
// Create a package
SpreadsheetMLPackage xlsPack = new SpreadsheetMLPackage
();
try {
xlsPack.
wb = new WorkbookPart
();
xlsPack.
wb.
setJaxbElement(
Context.
getsmlObjectFactory().
createWorkbook()
);
xlsPack.
addTargetPart(xlsPack.
wb);
Parsed in 0.014 seconds, using
GeSHi 1.0.8.4
and you can access it from the pkg, with pkg.getWorkbookPart()
So to glue in what I posted yesterday, use pkg.getWorkbookPart().getContents().setDefinedNames(definednames);