Spire.XLS for Java 4.4.6已发布。本次更新新增了setCustomPaperSize方法以自定义纸张大小的功能,优化Excel转HTML的功能,同时还修复了XLSX转XLSM数据被隐藏的问题。详情请阅读以下内容。
新功能:
workbook.getWorksheets().get(0).getPageSetup().setCustomPaperSize(100, 100);
问题修复:
Spire.PDF for Java 4.4.8已发布。该版本新增了移除JavaScript脚本的方法并且修复了提取文本时出现的问题。详情请阅读以下内容。
新功能:
PdfDocument pdf = new PdfDocument();
pdf.loadFromFile(input);
pdf.removeDocumentJavaScript();
pdf.saveToFile(output, FileFormat.PDF);
问题修复:
以下内容介绍使用Spire.XLS for Java 设置Excel表格视图模式的方法。
import com.spire.xls.*;
public class SetViewMode {
public static void main(String[] args) {
//加载Excel工作簿
Workbook wb = new Workbook();
wb.loadFromFile("test.xlsx");
//获取工作表
Worksheet sheet = wb.getWorksheets().get(0);
//设置工作表视图模式
//sheet.setViewMode(ViewMode.Normal);
sheet.setViewMode(ViewMode.Layout);
//sheet.setViewMode(ViewMode.Preview);
//保存文档
wb.saveToFile("SetViewMode.xlsx");
wb.dispose();
}
}
设置效果:

Spire.PDF 7.4.13已发布。该版本支持了在转换PDF到Excel时设置根据线条决定单元格的功能,新增了PrintSettings.IsValid属性的功能以判断打印机是否可以使用,增强了转换PDF到图片/Excel/XPS的功能,以及修复了打印PDF文档等时出现的问题。详情请阅读以下内容。
新功能:
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(PDFFile);
pdf.ConvertOptions.SetPdfToXlsxOptions(PdfToXlsxLayout.Line);
pdf.SaveToFile(ExcelFile, FileFormat.XLSX);
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(inputFile);
pdf.PrintSettings.PrinterName = @"Microsoft XPS Document Writer";
bool value = pdf.PrintSettings.IsValid;
问题修复:
获取Spire.PDF 7.4.13请点击:https://www.e-iceblue.cn/Downloads/Spire-PDF-NET.html
本文介绍如何使用Spire.XLS for Java在Excel表格中,用图片替换文字。
原文档:

import com.spire.xls.*;
import java.io.IOException;
public class ReplaceTextWithImage {
public static void main(String[] args) throws IOException {
//加载Excel示例文档
Workbook workbook = new Workbook();
workbook.loadFromFile("Sample.xlsx");
//获取第一张工作表
Worksheet worksheet = workbook.getWorksheets().get(0);
//查找文档中的字符串“图片”
CellRange[] ranges = worksheet.findAllString("{{图片}}", false, false);
for (CellRange range : ranges) {
//重置文本为空
range.setText("");
//获取单元格所在的行列
int row = range.getRow();
int column = range.getColumn();
//添加图片到获取的单元格
worksheet.getPictures().add(row, column, "logo.jpg", ImageFormatType.Jpeg);
//保存文档
workbook.saveToFile("replaceTextwithImage.xlsx", ExcelVersion.Version2013);
}
}
}
效果图:

Spire.Presentation for Java 4.4.2已发布。本次更新主要优化了插入图片耗时长的问题,并且增强了转换PPT到PDF的功能。此外,该版本还修复了加载PPT文档等时出现的问题。详情请阅读以下内容。
优化:
问题修复:
https://www.e-iceblue.cn/Downloads/Spire-Presentation-JAVA.html
在开发团队的共同努力之下,冰蓝科技于今日正式推出了Spire.Doc for Android via Java 2.4.0。该产品是一款专业的 Android Word 开发组件,用于 Android 应用程序中创建、转换、操作和打印 Word 文档。作为一款完全独立的组件,其运行环境无需安装 Microsoft Word。以下是该产品的主要功能:
https://www.e-iceblue.cn/Introduce/doc-for-android-via-java.html
本文介绍如何使用Spire.Doc for Java将ASCII字符设置为Word文档中的列表符号。
import com.spire.doc.*;
import com.spire.doc.documents.*;
import com.spire.doc.collections.ListLevelCollection;
public class SetBulletPoints {
public static void main(String[] args) {
//创建Document对象并添加节
Document doc = new Document();
Section section = doc.addSection();
//根据不同的ASCII字符创建四种不同的列表样式
ListStyle listStyle1 = doc.getStyles().add(ListType.Bulleted,"liststyle1");
ListLevelCollection levels1 = listStyle1.getListRef().getLevels();
levels1.get(0).setBulletCharacter("\u006e");
levels1.get(0).getCharacterFormat().setFontName("Wingdings");
ListStyle listStyle2 = doc.getStyles().add(ListType.Bulleted,"liststyle2");
ListLevelCollection levels2 = listStyle1.getListRef().getLevels();
levels2.get(0).setBulletCharacter("\u0075");
levels2.get(0).getCharacterFormat().setFontName("Wingdings");
ListStyle listStyle3 = doc.getStyles().add(ListType.Bulleted,"liststyle3");
ListLevelCollection levels3 = listStyle1.getListRef().getLevels();
levels3.get(0).setBulletCharacter("\u00b2");
levels3.get(0).getCharacterFormat().setFontName("Wingdings");
ListStyle listStyle4 = doc.getStyles().add(ListType.Bulleted,"liststyle4");
ListLevelCollection levels4 = listStyle1.getListRef().getLevels();
levels4.get(0).setBulletCharacter("\u00d8");
levels4.get(0).getCharacterFormat().setFontName("Wingdings");
//添加四个段落并分别应用列表样式
Paragraph p1 = section.getBody().addParagraph();
p1.appendText("Spire.Doc for .NET");
p1.getListFormat().applyStyle(listStyle1.getName());
Paragraph p2 = section.getBody().addParagraph();
p2.appendText("Spire.PDF for .NET");
p2.getListFormat().applyStyle(listStyle2.getName());
Paragraph p3 = section.getBody().addParagraph();
p3.appendText("Spire.XLS for .NET");
p3.getListFormat().applyStyle(listStyle3.getName());
Paragraph p4= section.getBody().addParagraph();
p4.appendText("Spire.Presentation for .NET");
p4.getListFormat().applyStyle(listStyle4.getName());
//保存到文档
doc.saveToFile("output/SetBulletCharacter.docx", FileFormat.Docx);
}
}

本文介绍使用Spire.Doc for Java删除Word目录的方法。
import com.spire.doc.*;
import com.spire.doc.documents.Paragraph;
public class RemoveTOC {
public static void main(String[]args){
//加载包含目录的Word文档
Document doc = new Document();
doc.loadFromFile("sample.docx");
//获取section
Section section = doc.getSections().get(0);
//遍历段落
for (int i = 0; i < section.getParagraphs().getCount(); i++)
{
Paragraph paragraph = section.getParagraphs().get(i);
if (paragraph.getStyleName().matches("TOC\\w+"))
{
section.getParagraphs().removeAt(i);//删除目录
i--;
}
}
//保存文档
doc.saveToFile("RemoveTOC.docx", FileFormat.Docx_2013);
doc.dispose();
}
}
目录删除效果前后:

Spire.XLS for Java支持将Word, Excel, PowerPoint幻灯片和PDF文档以OLE 对象嵌入到Excel工作表。本文将详细介绍如何使用Spire.Xls将Word文档作为OLE对象插入到Excel工作表。
import com.spire.xls.*;
import com.spire.xls.core.IOleObject;
import com.spire.doc.*;
import com.spire.doc.documents.ImageType;
import java.awt.image.BufferedImage;
public class insertOLEObjects {
public static void main(String[] args) {
String docFile = "Sample.docx";
String outputFile = "output/insertOLEObjects_result.xlsx";
//加载Excel文档
Workbook workbook = new Workbook();
workbook.loadFromFile("Sample.xlsx");
//获取第一张工作表
Worksheet worksheet = workbook.getWorksheets().get(0);
//生成图片
BufferedImage image = GenerateImage(docFile);
//插入OLE对象
IOleObject oleObject = worksheet.getOleObjects().add(docFile, image, OleLinkType.Embed);
oleObject.setLocation(worksheet.getCellRange("B4"));
oleObject.setObjectType(OleObjectType.ExcelWorksheet);
//保持文档
workbook.saveToFile(outputFile, ExcelVersion.Version2010);
}
private static BufferedImage GenerateImage(String fileName) {
//加载Word文档
Document document = new Document();
document.loadFromFile(fileName);
//将Word文档的第一页保存为图片
BufferedImage image = document.saveToImages(0, ImageType.Bitmap);
return image;
}
}
效果图:
