/** Inserts a new empty spreadsheet with the specified name. * @param aName The name of the new sheet. * @param nIndex The insertion index. * @return The XSpreadsheet interface of the new sheet. */ public unoidl.com.sun.star.sheet.XSpreadsheet insertSpreadsheet( String aName, short nIndex) { // Collection of sheets unoidl.com.sun.star.sheet.XSpreadsheets xSheets = mxDocument.getSheets(); xSheets.insertNewByName(aName, nIndex); unoidl.com.sun.star.sheet.XSpreadsheet xSheet = (unoidl.com.sun.star.sheet.XSpreadsheet) xSheets.getByName(aName).Value; return(xSheet); }
/** Returns the spreadsheet with the specified index (0-based). * @param nIndex The index of the sheet. * @return XSpreadsheet interface of the sheet. */ public unoidl.com.sun.star.sheet.XSpreadsheet getSpreadsheet(int nIndex) { // Collection of sheets unoidl.com.sun.star.sheet.XSpreadsheets xSheets = mxDocument.getSheets(); unoidl.com.sun.star.container.XIndexAccess xSheetsIA = (unoidl.com.sun.star.container.XIndexAccess)xSheets; unoidl.com.sun.star.sheet.XSpreadsheet xSheet = (unoidl.com.sun.star.sheet.XSpreadsheet) xSheetsIA.getByIndex(nIndex).Value; return(xSheet); }