最佳列宽OpenOffice Calc(Optimal Column Width OpenOffice Calc)

编程入门 行业动态 更新时间:2024-10-09 12:34:53
最佳列宽OpenOffice Calc(Optimal Column Width OpenOffice Calc)

我正在将CSV文件中的数据输入OpenOffice电子表格。

此代码在电子表格中获取新工作表:

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

然后,我有一个方法,一次将一个列表输入一个单元格的单元格区域。 我希望能够自动设置这些单元格的列大小。 这是什么样的

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); ((XText)tableData).setString(finalDataCell); column Value++; if(columnValue > = numberOfColumns) { rowVal++ column = 0; } }

谷歌搜索后,我找到了功能:

在http://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=31292上的columns.OptimalWidth = True

但我不确定如何使用它。 任何人都可以进一步解释这一点或想到另一种让细胞自动调整的方法吗?

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

This code gets the a new sheet in a spreadsheet:

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

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); ((XText)tableData).setString(finalDataCell); 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/viewtopic.php?f=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?

最满意答案

我理解代码中的注释是西班牙语,但我的代码是英文的。 我通过谷歌翻译运行评论,所以现在他们用英语。 我从这里复制了它:

//Auto Enlarge col width private void largeurAuto(string NomCol) { XCellRange Range = null; Range = Sheet.getCellRangeByName(NomCol + "1"); //Recover the range, a cell is XColumnRowRange RCol = (XColumnRowRange)Range; //Creates a collar ranks XTableColumns LCol = RCol.getColumns(); // Retrieves the list of passes uno.Any Col = LCol.getByIndex(0); //Extract the first Col XPropertySet xPropSet = (XPropertySet)Col.Value; xPropSet.setPropertyValue("OptimalWidth", new one.Any((bool)true)); }

这是做什么的:首先它获取范围名称,然后获取第一列。 但是,真正的代码是使用XpropertySet,这在这里解释得非常好。

I understand the comments in the code are in Spanish I think, but the code is in English. I ran the comments through Google translate so now they are in English. I copied it from here:

//Auto Enlarge col width private void largeurAuto(string NomCol) { XCellRange Range = null; Range = Sheet.getCellRangeByName(NomCol + "1"); //Recover the range, a cell is XColumnRowRange RCol = (XColumnRowRange)Range; //Creates a collar ranks XTableColumns LCol = RCol.getColumns(); // Retrieves the list of passes uno.Any Col = LCol.getByIndex(0); //Extract the first Col XPropertySet xPropSet = (XPropertySet)Col.Value; xPropSet.setPropertyValue("OptimalWidth", new one.Any((bool)true)); }

What this does it this: First it gets the range name and then gets the first column. The real code, though, is XpropertySet being used, which is explained REALLY well here.

更多推荐

本文发布于:2023-08-04 21:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1421475.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Calc   OpenOffice   Optimal   Width   Column

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!