0
我正在嘗試使用Java創建Excel表單。我通過創建一個Workbook對象並在其中創建一個WritabeSheet對象,將數據填充到Excel表格中。我想將默認大小設置爲WritableSheet對象中的單元格。我怎麼做?在創建Excel文檔時設置默認單元格大小
下面的代碼片段:
private static void writeDataSheet(WritableSheet s, String str, int i)
throws Exception{
//Format the font
WritableFont wf = new WritableFont(WritableFont.ARIAL,
10, WritableFont.BOLD);
WritableCellFormat cf = new WritableCellFormat(wf);
cf.setWrap(true);
//Create label and write data to one cell of sheet
Label l = new Label(0,i,str,cf);
s.addCell(l);
// I want to set a default size to the columns in the excel sheet here
}
PS:本sheet.autoSizeColumn()不能用於WritableSheet工作!
另外,是有可能自動擴展每個單元格以適應寫入它的文本? – gravetii
答案是否適合你? – shahkalpesh