Spire.XLS for Java是专业的Java Excel API,使开发人员无需使用Microsoft Office或Microsoft Excel即可创建,管理,操作,转换和打印Excel工作表。
本文将演示如何在Java应用程序中使用Spire.XLS for Java将Excel转换为SVG流。下载Spire.XLS最新版
代码如下:
import com.spire.xls.*;
import java.io.FileOutputStream;
import java.util.List;
import java.util.Map;
public class ExceltoSVG {
public static void main(String[] args) throws Exception {
//Load the sample document
Workbook workbook = new Workbook();
workbook.loadFromFile("Sample.xlsx");
int count = 1;
//Get the page split info.
List> pageInfoList = workbook.getSplitPageInfo();
for (int i = 0; i < workbook.getWorksheets().getCount(); i++) { FileOutputStream stream; Worksheet sheet = workbook.getWorksheets().get(i); Map integerPageColRowMap = pageInfoList.get(i); for (Map.Entry entry : integerPageColRowMap.entrySet()) { PageColRow colRow = entry.getValue(); stream=new FileOutputStream("output/out" + (count++) + ".svg"); //Save to SVG sheet.toSVGStream(stream, colRow.StartRow, colRow.StartCol, colRow.EndRow, colRow.EndCol); stream.flush(); stream.close(); } } } }
输出结果:



使用Spire.XLS for Java,开发者可以在不依赖Microsoft Office或Excel的情况下,轻松实现Java应用中Excel到SVG的转换。该API允许创建、管理和转换Excel工作表。以下是转换的示例代码。

被折叠的 条评论
为什么被折叠?



