Aspose.Cells for Java发布了新的8.9版本

作者:控件中国网   出处:控件中国网   2016-07-26 10:06:07   阅读:6

Aspose.Cells for Java 是一款全球顶尖的无图形界面的Excel文档处理控件,可以实现几乎所有Microsoft Excel的功能,无论是桌面应用还是Web应用都可以很好的对Excel进行各种操作处理,随着该产品版本的不断更新,功能是越来越完善,在这次8.9版本的更新中主要做了如下的增强与修复:
在新的版本中当显示Spreadsheets为图片格式时可以通过ImageOrPrintOptions.DefaultFont属性来设置默认字体了
Workbook wb = new Workbook();
//Set default font of the workbook to none
Style s = wb.getDefaultStyle();
s.getFont().setName("");
wb.setDefaultStyle(s);
//Access first worksheet.
Worksheet ws = wb.getWorksheets().get(0);
//Access cell A4 and add some text inside it.
Cell cell = ws.getCells().get("A4");
cell.putValue("This text has some unknown or invalid font which does not exist.");
 
//Set the font of cell A4 which is unknown.
Style st = cell.getStyle();
st.getFont().setName("UnknownNotExist");
st.getFont().setSize(20);
st.setTextWrapped(true);
cell.setStyle(st);
 
//Set first column width and fourth column height
ws.getCells().setColumnWidth(0, 80);
ws.getCells().setRowHeight(3, 60);
 
//Create image or print options.
ImageOrPrintOptions opts = new ImageOrPrintOptions();
opts.setOnePagePerSheet(true);
opts.setImageFormat(ImageFormat.getPng());
 
//Render worksheet image with Courier New as default font.
opts.setDefaultFont("Courier New");
SheetRender sr = new SheetRender(ws, opts);
sr.toImage(0, "out_courier_new.png");
 
//Render worksheet image again with Times New Roman as default font.
opts.setDefaultFont("Times New Roman");
sr = new SheetRender(ws, opts);
sr.toImage(0, "out_times_new_roman.png");
当转换Excel工作表为HTML时,可以通过HtmlSaveOptions类的DefaultFontName属性来设置默认字体
//Directory path where output HTML files are to be saved
String dirPath = "D:\\Downloads\\";
//Create workbook object.
Workbook wb = new Workbook();
//Access first worksheet.
Worksheet ws = wb.getWorksheets().get(0);
//Access cell B4 and add some text inside it.
Cell cell = ws.getCells().get("B4");
cell.putValue("This text has some unknown or invalid font which does not exist.");
//Set the font of cell B4 which is unknown.
Style st = cell.getStyle();
st.getFont().setName("UnknownNotExist");
st.getFont().setSize(20);
cell.setStyle(st);
//Now save the workbook in html format and set the default font to Courier New.
HtmlSaveOptions opts = new HtmlSaveOptions();
opts.setDefaultFontName("Courier New");
wb.save(dirPath + "out_courier_new.htm", opts);
//Now save the workbook in html format once again but set the default font to Arial.
opts.setDefaultFontName("Arial");
wb.save(dirPath + "out_arial.htm", opts);
//Now save the workbook in html format once again but set the default font to Times New Roman.
opts.setDefaultFontName("Times New Roman");
wb.save(dirPath + "out_times_new_roman.htm", opts);
当刷新数据透视表时提高了对Excel 2003的兼容性
对控件的SheetRender进行了增强,如复选框
 
Copyright© 2006-2015 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 渝ICP备12000264号 法律顾问:元炳律师事务所
客服软件
live chat