0
1

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 3 years have passed since last update.

C#  ExcelをSVGに変換

Last updated at Posted at 2021-07-15

今回はC#ではSpire.XLSという無料のライブラリを活用して、Excel文書をSVGに変換する方法を紹介してさしあげましょう。

下準備

1.E-iceblueの公式サイトからFree Spire.XLS無料版をダウンロードしてください。

f:id:lendoris:20210715110247p:plain
2.Visual Studioを起動して新規プロジェクトを作成してから、インストールされたファイルにあった相応しいSpire.XLS.dllを参照に追加してください。

(Net 4.0を例としたら、デフォルトパスは“Bin→NET4.0→XLS.dll”というようです。)

f:id:lendoris:20210715110259p:plain

 

f:id:lendoris:20210715110319p:plain

```c# using System.Drawing.Imaging; using System.IO; namespace Convert { class Program { static void Main(string[] args) { //ファイルをロードします。 Workbook workbook = new Workbook(); workbook.LoadFromFile("Sample.xlsx");
        //ToSVGStream(Stream stream)メソッドでシートを別々にSVGで保存   
     for (int i = 0; i < workbook.Chartsheets.Count; i++)
        {
            FileStream fs = new FileStream(string.Format("chartsheet-{0}.svg", i), FileMode.Create);
            workbook.Chartsheets[i].ToSVGStream(fs);
            fs.Flush();
            fs.Close();
        }


    }
}

}

<h4><strong> 実行結果</strong></h4>
<p><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/l/lendoris/20210715/20210715110328.png" alt="f:id:lendoris:20210715110328p:plain" width="522" height="561" loading="lazy" title="" class="hatena-fotolife" itemprop="image" /></p>
<p> </p>
0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?