Optimal Column Width OpenOffice Calc

Keyboard macros or custom scripts

Optimal Column Width OpenOffice Calc

Postby Dunkley296 » Thu Jan 10, 2019 11:30 am

I'm entering data from a CSV file into a OpenOffice spreadsheet.

This code gets the a new sheet in a spreadsheet:

Code: Select all   Expand viewCollapse view
Public Spreadsheet getSpreadsheet(int sheetIndex, XComponent xComp)
  XSpreadsheet xSheets = ((XSpreadsheetDocument)xComp).getSheets();
  XIndexAccess xSheetIA = (XIndexAccess)xSheets;
  XSpreadsheet XSheet = (XSpreadsheet)xSheetsA.getByIndex(sheetIndex).Value;
  return XSheet;

I then have method that enters a list into a cell range one cell at a time. I want to be able to automatically set the column size for these cells. which is something like

Code: Select all   Expand viewCollapse view
string final DataCell;
Xspreadsheet newSheet = getSpreadsheet(sheetIndex, xComp);
int numberOfRecords = ( int numberOfColumns * int numberOfRows);
for(cellNumber = 0; cellNumber < numberOfrecords; cellNumber++)
  XCell tableData = newSheet.getCellbyPosition(columnValue, rowValue);
  column Value++;
  if(columnValue > = numberOfColumns)
    rowVal++ column = 0;

After googling i have found the function:

columns.OptimalWidth = True on http://forum.openoffice.org/en/forum/vi ... 20&t=31292

but im unsure on how to use this. Could anyone explain this further or think of another way to have the cell autofit?
Posts: 1
Joined: Thu Jan 10, 2019 11:26 am

Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 0 guests