Database Import

From Apache OpenOffice Wiki
< Documentation‎ | DevGuide
Revision as of 15:51, 3 January 2021 by DiGro (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The interface imports data from an external data source (database) into spreadsheet cells. The database has to be registered in Apache OpenOffice API, so that it can be selected using its name. The doImport call takes a sequence of property values that select the data to import.

Similar to the sort descriptor, the import descriptor's sequence of property values can be constructed from scratch, or the return value of the createImportDescriptor() method can be used and modified. The createImportDescriptor() method returns a description of the previously imported data if the cell range is a database range with stored import settings and the bEmpty parameter is false.


The DatabaseName property selects a database. The SourceType selects the kind of object from the database that is imported. It can have the following values:

  • If SourceType is TABLE, the whole table that is named by SourceObject is imported.
  • If SourceType is QUERY, the SourceObject must be the name of a named query.
  • If SourceType is SQL, the SourceObject is used as a literal SQL command string.

If a database name is in the aDatabase variable and a table name in aTableName, the following code imports that table from the database:

  // --- import from database ---[] aImportDesc = new[3];
  aImportDesc[0] = new;
  aImportDesc[0].Name = "DatabaseName";
  aImportDesc[0].Value = aDatabase;
  aImportDesc[1] = new;
  aImportDesc[1].Name = "SourceType";
  aImportDesc[1].Value =;
  aImportDesc[2] = new;
  aImportDesc[2].Name = "SourceObject";
  aImportDesc[2].Value = aTableName; xImportRange = xSheet.getCellRangeByName("B33:B33"); xImport = ( )
      UnoRuntime.queryInterface(, xImportRange);
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages