0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Please tell me how to convert excel file to svg file programatically

Posted at

There are several ways you can convert an Excel file to an SVG file programmatically. One option is to use a library that is capable of reading and writing Excel files, such as the npm package "xlsx", and then use a library that is capable of converting from the Excel format to SVG format, such as the npm package "excel-to-svg".

Here is an example of how you could use these libraries to convert an Excel file to an SVG file in a Node.js application:

Install the xlsx and excel-to-svg packages:
Copy code
npm install xlsx excel-to-svg
Import the packages in your Node.js script:
Copy code
const xlsx = require('xlsx');
const excelToSvg = require('excel-to-svg');
Use the readFile function from the xlsx package to read the Excel file into memory:
Copy code
const workbook = xlsx.readFile('/path/to/input.xlsx');
Use the worksheetToSvg function from the excel-to-svg package to convert the worksheet to an SVG string:
Copy code
const worksheet = workbook.Sheets[workbook.SheetNames[0]];
const svg = excelToSvg(worksheet);
Write the SVG string to a file using the writeFileSync function from the built-in fs module:
Copy code
const fs = require('fs');

fs.writeFileSync('/path/to/output.svg', svg);
This example converts the first worksheet in the Excel file to an SVG file. If you want to convert a specific worksheet, you can use the workbook.Sheets object to get a reference to the worksheet by its name, and pass it to the excelToSvg function.

Copy code
const worksheet = workbook.Sheets['My Worksheet'];
const svg = excelToSvg(worksheet);
I hope this helps! Let me know if you have any questions.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?