title: Inserting Sheets in Spreadsheet through c#
body: <p>I have created a a project that reads different files and puts then in different sheets with a spreadsheet. 
  I have used Open office calc spreadsheet therefore used the following code to open a blank file: </p>
  
  <pre><code>public XSpreadsheet getSpreadsheet(int nIndex, XComponent xComp)
  {
      XSpreadsheets xSheets = ((XSpreadsheetDocument)xComp).getSheets();
      XIndexAccess xSheetsIA = (XIndexAccess)xSheets;
      XSpreadsheet xSheet =(XSpreadsheet)xSheetsIA.getByIndex(nIndex).Value;
  
      return xSheet;         
  }
  </code></pre>
  
  <p>I call a sheet to be used like so:</p>
  
  <pre><code>XSpreadsheet newSheet = getSpreadsheet(sheetIndex, xComp);
  </code></pre>
  
  <p>where <code>xComp</code> is:</p>
  
  <pre><code>string filePathway = @"file:///c:/temp/blank.ods";  
  PropertyValue[] propVals = new PropertyValue[0];
  XComponent oCalcuDoc = oDesktop.loadComponentFromURL(filePathway, "_blank", 0, propVals);
  </code></pre>
  
  <p>However my problem is that file blank.ods needs to be set up with the number of sheets that will be required already inserted into the spreadsheet before the application is run. This is not ideal as the number of sheets needed is not always known. Is there a way of inserting sheets from within my application?</p>
  
  <p>Any help would be appreciated.</p>