Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我可以调整Excel列的宽度而不单独设置它们吗?_Excel_Coldfusion_Formatting_Cfspreadsheet - Fatal编程技术网

我可以调整Excel列的宽度而不单独设置它们吗?

我可以调整Excel列的宽度而不单独设置它们吗?,excel,coldfusion,formatting,cfspreadsheet,Excel,Coldfusion,Formatting,Cfspreadsheet,我正在使用cfspreadsheet使用ColdFusion生成Excel电子表格。我插入一个标题行,然后使用spreadsheetAddRows将查询转储到工作表中。问题是这些柱子通常不够宽。我知道我可以使用spreadsheetcolumnwidth单独调整每一列,但是否有任何方法可以将自动宽度应用于整个工作表?我不知道每列的最大宽度,也不想将其单独应用于每列。Excel有一个列的自动宽度功能-有没有办法从ColdFusion代码触发它?(或者更好:我是否可以添加到自动宽度-将每列设置为最大

我正在使用
cfspreadsheet
使用ColdFusion生成Excel电子表格。我插入一个标题行,然后使用
spreadsheetAddRows
将查询转储到工作表中。问题是这些柱子通常不够宽。我知道我可以使用
spreadsheetcolumnwidth
单独调整每一列,但是否有任何方法可以将自动宽度应用于整个工作表?我不知道每列的最大宽度,也不想将其单独应用于每列。Excel有一个列的自动宽度功能-有没有办法从ColdFusion代码触发它?(或者更好:我是否可以添加到自动宽度-将每列设置为最大宽度+2或其他?

上次我检查时,没有记录的CF函数。但是,您可以使用POI的方法自动调整每个列的大小。只需注意,POI对表索引和列索引使用零基

<cfscript>
    // create a workbook and add a long value
    wb = SpreadSheetNew();
    spreadSheetSetCellValue(wb, repeatString("x", 200), 1, 1);
    // get the first sheet
    sheet = wb.getWorkBook().getSheetAt( javacast("int", 0) );
    // resize first column ie "A"
    sheet.autoSizeColumn( javacast("int", 0) );
    spreadSheetWrite( wb, "c:/test.xls", true ); 
</cfscript>

//创建工作簿并添加长值
wb=电子表格新建();
spreadSheetSetCellValue(wb,repeatString(“x”,200),1,1);
//拿到第一张
sheet=wb.get工作簿().getSheetAt(javacast(“int”,0));
//调整第一列的大小,即“A”
sheet.autoSizeColumn(javacast(“int”,0));
电子表格书写(wb,“c:/test.xls”,真);