[Calc] Set value for a cell with Javascript
Posted: Fri Jul 26, 2019 9:03 am
Dear forum,
This code set a string for a cell
But I need to set A1 cell with 12345 as value.
I don't know what class I should call to do it.
Thanks
This code set a string for a cell
Code: Select all
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.sheet.XSpreadsheetDocument);
importClass(Packages.com.sun.star.sheet.XSpreadsheets);
importClass(Packages.com.sun.star.table.XCellRange);
importClass(Packages.com.sun.star.text.XTextRange);
importClass(Packages.com.sun.star.container.XIndexAccess);
oDoc = XSCRIPTCONTEXT.getDocument();
xSpreadsheetDocument = UnoRuntime.queryInterface(XSpreadsheetDocument, oDoc);
oSpreadsheets = xSpreadsheetDocument.getSheets();
oIndexAccess = UnoRuntime.queryInterface(XIndexAccess, oSpreadsheets);
oSheet = oIndexAccess.getByIndex(0);
oCellRange = UnoRuntime.queryInterface(XCellRange, oSheet);
OutRange = oCellRange.getCellRangeByName("A1");
oTextRange = UnoRuntime.queryInterface(XTextRange,OutRange);
oTextRange.setString("12345");
I don't know what class I should call to do it.
Thanks