sneeze snoeze

sneeze snoeze

  • 2.1k
  • 5
  • 11.2k

Create excel file from c# with formula's and subtotals

Sep 27 2014 3:49 PM

I want to create a excel file using Microsoft.Office.Interop.Excel;

In this excel file a lot of data from a database.

I am using subtotals to group the data

worksheet_range.Cells.Subtotal(1, Excel.XLConsolidationFunction.xlSum, new[] {7,8}, false)

Beside the data from the database, I want to add some column with formula's into the excel sheet.

worksheet.get_Range(C1, Type.Missing).EntireColumn.Formula = "=A1+B1";

When I add the columns with the  formula's first  to the excel sheet and apply the subtotals after that, I do get the following errormessage

To prevent possible loss of data, Excel cannot shift nonblank cells off of the worksheet

How can I add columns with fomula's in my excelsheet and use subtotal at the same time ?


Answers (2)