我们使用aspose生成的excel文件不支持自适应行高
image.png (4.7 KB)
代码如下:
import com.aspose.cells.CountryCode;
import com.aspose.cells.LoadOptions;
import com.aspose.cells.MemorySetting;
import com.aspose.cells.Workbook;
import com.aspose.cells.WorkbookDesigner;
public class Demo {
// 单元格数据
private static final String docData = “ooooooooooooooooooooooooooooooooooooooooooooooooooooofffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffddddddddddddddddddddddddddddsdflskjfls;jfl;dskjfs;jfds;jfds;djfds;fjkdjfdfdfdfdfdfdfdfxuechaochao \nHansaallee 205 \nD-40549 Düsseldorf\nWEEE Reg. Number – 39372368.\nRegistered Office: Düsseldorf, Register Court Düsseldorf, HRB 72992, \nManaging Director: Mr. Bo PENG *Tax no.: 103 5734 1583 * Tax ID: DE 221 644 379”;
public static void main(String[] args) throws Exception {
// 模板文件地址
String templateFilePath = “D:\demo5\文档生成合并单元格temp.xlsx”;
// 生成的文件地址
String objectivesFilePath = “D:\demo5\文档生成合并单元格temp——out_1.xlsx”;
LoadOptions opt = new LoadOptions();
opt.setParsingFormulaOnOpen(false);
opt.setRegion(CountryCode.USA);
// 设置为大文件模式
opt.setMemorySetting(MemorySetting.MEMORY_PREFERENCE);
Workbook template = new Workbook(templateFilePath,opt);
template.calculateFormula(true);
template.getSettings().setEnableMacros(true);
template.getSettings().setReCalculateOnOpen(true);
template.getSettings().setRecalculateBeforeSave(true);
WorkbookDesigner designer = new WorkbookDesigner();
designer.setCalculateFormula(true);
designer.setWorkbook(template);
designer.setDataSource(“COMPANY_ADDRESS”,docData);
designer.process();
designer.getWorkbook().save(objectivesFilePath);
}
}
具体附件如下:
demo.zip (48.1 KB)