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

ピボットテーブルを配置したExcelファイルを処理する

0
Posted at

目的

C#のアプリで、ピボットテーブルを配置した既存のExcelファイル(対象ファイル)にデータを追加し、保存する。

失敗例

  • ClosedXMLでは、対象ファイルを読み込んで、データを追加後、保存しようとすると、時間がかかりすぎる。現時点では、ピボットテーブルがあるファイルのClosedXMLでの処理は難がある。
  • C1.WPF.Excelでは、ピボットテーブルが保存後、利用できなくなる(処理できない)。
  • Microsoft.Office.Interop.Excelを利用して、対象ファイルを開き、データを追加し、保存するのはOKだが、データの追加に時間がかかりすぎる。

解決策

  1. ClosedXMLで追加するデータを作成し、一端、xlsxとして保存する(データソース)。
  2. 次に、Interop.Excelを利用して、対象ファイルと、データソースを開き、データソースから、対象ファイルに、データをコピーする。(RangeからRangeへコピー)

考え

データのコピーは、対象ファイル上のExcel VBAでコピーを行っても良いだろう。

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?