作成日: 2025/04/18 最終更新日: 2025/07/09
文書種別
不具合
状況
修正済み
詳細
複数シートを含むテンプレートファイルを読み込み、最初のシートを削除後にProcessTemplateメソッドを実行すると、次のような例外が発生します。
System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')'
System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')'
回避方法
この問題はバージョン8.1.3で修正されました。
※修正版を適用しない場合の回避方法は以下の通りです。
ProcessTemplateメソッドの実行前に、一度ワークブックを保存してから再読み込みを行ってください。
※修正版を適用しない場合の回避方法は以下の通りです。
ProcessTemplateメソッドの実行前に、一度ワークブックを保存してから再読み込みを行ってください。
workbook.Worksheets[0].Delete(); // 回避策 MemoryStream memoryStream = new MemoryStream(); workbook.Save(memoryStream, SaveFileFormat.Xlsx); memoryStream.Position = 0; workbook.Open(memoryStream, OpenFileFormat.Xlsx); ・・・ workbook.ProcessTemplate();