Hello,
I am inserting data from code, In my excel file I have already inserted table, which only contain structure not data. the problem is, table is not resizing after adding data,
am I missing out on something? Please reply asap
...
for (int i = 1;i<= sheet.Rows.Length;i++)
{
sheet.AutoFitRow(i);
}
for (int j = 1; j <= sheet.Columns.Length; j++)
{
sheet.AutoFitColumn(j);
}
...
Workbook workbook = new Workbook();
workbook.LoadFromFile("snopformulaexpand.xlsx");
Worksheet ws0 = workbook.Worksheets[0];
Worksheet ws1 = workbook.Worksheets[1];
ws0.Range["A10"].Value = "SKU9"; ws1.Range["A10"].Value = "SKU9";
ws0.Range["B10"].Value = "Customer9"; ws1.Range["B10"].Value = "Customer9";
ws0.Range["C10"].NumberValue = 1; ws1.Range["C10"].NumberValue = 1;
ws0.Range["D10"].NumberValue = 2; ws1.Range["D10"].NumberValue = 2;
ws0.Range["E10"].NumberValue = 3; ws1.Range["E10"].NumberValue = 3;
ws0.Range["F10"].NumberValue = 4; ws1.Range["F10"].NumberValue = 4;
ws0.Range["G10"].NumberValue = 5; ws1.Range["G10"].NumberValue = 5;
ws0.ListObjects.Single(i => i.Name == "Table1").Location = ws0.Range[1, 1, ws0.LastRow, ws0.LastColumn];
ws1.ListObjects.Single(i => i.Name == "Table2").Location = ws1.Range[1, 1, ws1.LastRow, ws1.LastColumn];
Worksheet sheet = workbook.Worksheets[2];
sheet.Range["A10"].Formula = sheet.Range["A9"].Formula;
sheet.Range["B10"].Formula = sheet.Range["B9"].Formula;
sheet.Range["C10"].Formula = sheet.Range["C9"].Formula;
sheet.Range["D10"].Formula = sheet.Range["D9"].Formula;
sheet.Range["E10"].Formula = sheet.Range["E9"].Formula;
sheet.Range["F10"].Formula = sheet.Range["F9"].Formula;
sheet.Range["G10"].Formula = sheet.Range["G9"].Formula;
string result = "result.xlsx";
workbook.SaveToFile(result, ExcelVersion.Version2010);