Spire.XLS for Java is a professional Java Excel API that enables developers to create, manage, manipulate, transform, and print Excel worksheets without using Microsoft Office or Microsoft Excel.

This article demonstrates how to convert Excel into an SVG stream using Spire.xls for Java in a Java application. Download the latest version of Spire.xls

The code is as follows:

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(); }}}}Copy the code

Output result: