Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8484011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:15:52+00:00 2026-06-10T20:15:52+00:00

I have created a a project that reads different files and puts then in

  • 0

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:

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;         
}

I call a sheet to be used like so:

XSpreadsheet newSheet = getSpreadsheet(sheetIndex, xComp);

where xComp is:

string filePathway = @"file:///c:/temp/blank.ods";  
PropertyValue[] propVals = new PropertyValue[0];
XComponent oCalcuDoc = oDesktop.loadComponentFromURL(filePathway, "_blank", 0, propVals);

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?

Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:15:54+00:00Added an answer on June 10, 2026 at 8:15 pm

    I just took a brief look at the OpenOffice API and found this: http://www.openoffice.org/api/docs/common/ref/com/sun/star/sheet/XSpreadsheets.html

    .. it states that the interface XSpreadsheets:

    provides methods to access the spreadsheets by name and to insert, copy, remove and rearrange spreadsheets.

    It includes methods like:

    insertNewByName, which according to the API documentation:

    inserts a new sheet into the collection.

    see: http://www.openoffice.org/api/docs/common/ref/com/sun/star/sheet/XSpreadsheets.html#insertNewByName

    … and so on.

    I’m by no means an OpenOffice API expert – I just took a brief view at their API documenation – hope this can point you in the right direction.

    Actually, the documentation contains an example of how to add a new sheet in a document:

     /** Inserts a new empty spreadsheet with the specified name.
     @param xDocument The XSpreadsheetDocument interface of the document.
     @param aName The name of the new sheet.
     @param nIndex The insertion index.
     @return The XSpreadsheet interface of the new sheet.
     */
     public com.sun.star.sheet.XSpreadsheet insertSpreadsheet(
         com.sun.star.sheet.XSpreadsheetDocument xDocument,
         String aName, short nIndex ) {
    
         // Collection of sheets
         com.sun.star.sheet.XSpreadsheets xSheets = xDocument.getSheets();
         com.sun.star.sheet.XSpreadsheet xSheet = null;
    
         try {
             xSheets.insertNewByName(aName, nIndex);
             xSheet = xSheets.getByName( aName );
         } catch (Exception ex) {
         }
    
         return xSheet;
     } 
    

    The example can be seen at the bottom of this page: http://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Working_With_Spreadsheet_Documents

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently just created Java project using Eclipse that requires 2 JAR files
I created a new cordova project on XCODE, I have some files that I
I have created a project that uses scala that has some abstract classes definitions
I have created a new method in one of the project's controllers that it
I have created several DLL (.NET) libraries that are used in several projects. In
In my current project, I have a lot of binary files of different formats.
I have a Swing Java program that reads *.txt files in a resource folder
I'm in a situation where I have to create a project that's a mixture
Good day, I have a library project that i use to create a paid
For a project we have a requirement to create an interfacedefinition that will return

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.