3
5

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

ReportViewer で拡張子xlsxのExcelへExport

Last updated at Posted at 2015-07-01

#はじめに
ReportViewer をWinFormで使い、簡単にExportできないか調査したところ、旧型式(拡張子xls)は簡単にExportができた。
参照ページreportViewerでエクスポートを自動化させるのとおりにすると、xlsのExcelになる。
#拡張子xlsxにする方法
単純に、「Excel」を「EXCELOPENXML」に変更するだけでExportできた。

var bytes = reportViewer1.ServerReport.Render("EXCELOPENXML");
using (var fs = new FileStream("test.xlsx", FileMode.Create))
    fs.Write(bytes, 0, bytes.Length);

#HTMLにする方法
追記でHTMLで出力する方法は「HTML4.0」を指定する。

var bytes = reportViewer1.ServerReport.Render("HTML4.0");
using (var fs = new FileStream("test.html", FileMode.Create))
    fs.Write(bytes, 0, bytes.Length);
3
5
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
3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?