Java Code Examples for com.sun.star.text.XText#setString()
The following examples show how to use
com.sun.star.text.XText#setString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Snippet15.java From noa-libre with GNU Lesser General Public License v2.1 | 5 votes |
public static void main(String[] args) { try { IOfficeApplication officeAplication = OfficeApplicationRuntime.getApplication(configuration); officeAplication.setConfiguration(configuration); officeAplication.activate(); IDocumentService documentService = officeAplication.getDocumentService(); IDocument document = documentService.constructNewDocument(IDocument.CALC, DocumentDescriptor.DEFAULT); ISpreadsheetDocument spreadsheetDocument = (ISpreadsheetDocument) document; XSpreadsheets spreadsheets = spreadsheetDocument.getSpreadsheetDocument().getSheets(); String sheetName= "Sheet1"; Object[][] rows = new Object[][]{ new Object[]{"DataCell1","DataCell2","DataCell3","DataCell4"}, new Object[]{new Integer(10),new Integer(20),new Integer(30),new Integer(40)}, new Object[]{new Double(11.11),new Double(22.22),new Double(33.33),new Double(44.44)}}; XSpreadsheet spreadsheet1 = (XSpreadsheet)UnoRuntime.queryInterface(XSpreadsheet.class,spreadsheets.getByName(sheetName)); //insert your Data XSheetCellCursor cellCursor = spreadsheet1.createCursor(); for(int i = 0; i < rows.length; i++) { Object[] cols = rows[i]; for(int j = 0; j < cols.length; j++) { XCell cell= cellCursor.getCellByPosition(j,i); XText cellText = (XText)UnoRuntime.queryInterface(XText.class, cell); Object insert = cols[j]; if(insert instanceof Number) cell.setValue(((Number)insert).doubleValue()); else if(insert instanceof String) cellText.setString((String)insert); else cellText.setString(insert.toString()); } } } catch (Throwable exception) { exception.printStackTrace(); } }
Example 2
Source File: TextTable.java From noa-libre with GNU Lesser General Public License v2.1 | 3 votes |
/** * Sets data of cell with the submitted name. * * @param cellName name of the cell * @param xTextContent content to be inserted * * @throws Exception if any error occurs * * @author Andreas Bröker */ public void setCellData(String cellName, XTextContent xTextContent) throws Exception { XCell xCell = xTextTable.getCellByName(cellName); XText xText = (XText) UnoRuntime.queryInterface(XText.class, xCell); xText.setString(""); xText.insertTextContent(xText.getStart(), xTextContent, true); }
Example 3
Source File: TextTable.java From noa-libre with GNU Lesser General Public License v2.1 | 2 votes |
/** * Sets data of the cell with the submitted name. * * @param cellName name of the cell * @param content content to be inserted * * @throws Exception if any error occurs * * @author Andreas Bröker */ public void setCellData(String cellName, String content) throws Exception { XCell xCell = xTextTable.getCellByName(cellName); XText xText = (XText) UnoRuntime.queryInterface(XText.class, xCell); xText.setString(content); }