文档彩票走势图>>Spire.XLS 系列教程>>Spire.XLS教程:在Java中以编程方式将Excel转换为SVG
Spire.XLS教程:在Java中以编程方式将Excel转换为SVG
Spire.XLS for Java是专业的Java Excel API,使开发人员无需使用Microsoft Office或Microsoft Excel即可创建,管理,操作,转换和打印Excel工作表。
本文将演示如何在Java应用程序中使用Spire.XLS for Java将Excel转换为SVG流。
代码如下:
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(); } } } }
输出结果: