2017-08-28 40 views
0

從我執行的一些實驗以及通過讀取this page可以看出,Excel中列寬度和行高的默認測量單位不是像素,甚至不是標準度量如釐米,但它們是適合空間的字符數。以像素爲單位獲取Excel列的寬度而不是默認的測量單位

我正在使用Aspose Cells for Java。如何以像素爲單位獲取列的寬度?

+0

我認爲你錯了,按照:https://support.office.com/en-us/article/Change-the-column-width-and-row-height-72f5e3cc-994d-43e8-ae58- 9774a0905f46 – Luuklag

回答

1

那麼,您可以嘗試使用Cells.getColumnWidthPixel()以像素爲單位獲取列的寬度,請參閱示例代碼以供參考。 e.g 示例代碼:

Workbook wb = new Workbook("Book1.xlsx"); 
Worksheet ws = wb.getWorksheets().get(0); 
Cells cells = ws.getCells(); 

//Get the second column's width in pixels, i.e, B. 
int colwidth = cells.getColumnWidthPixel(1); 

System.out.println(colwidth); 

同樣,你可以嘗試使用Cells.getRowHeightPixel()來獲得在像素行的高度。

我在Aspose擔任支持開發人員/宣傳員。

相關問題