Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: Cell.Value throwing System.FormatException

$
0
0
I have the same error in the Excel file.
If I copy paste the formula in the excel file = value is correct.
        DataTable tbl_rez = new DataTable();
        tbl_rez.Columns.Add("V", typeof(int));
        for (int i = 1; i < 18; i++)
        {
            DataRow r1 = tbl_rez.NewRow();
            r1[0]=i;
            tbl_rez.Rows.Add(r1);
        }
        var workbook2 = new XLWorkbook();
        var worksheet2 = workbook2.Worksheets.Add("List1");
        worksheet2.PageSetup.PageOrientation = XLPageOrientation.Landscape;

        worksheet2.Cell(1, 1).InsertTable(tbl_rez.AsEnumerable());

        workbook2.CalculateMode = XLCalculateMode.Auto;
        workbook2.ReferenceStyle = XLReferenceStyle.R1C1;


        var cellWithFormulaR1C1 = worksheet2.Cell(1 + tbl_rez.Rows.Count, 1);
        // In Russia
        cellWithFormulaR1C1.FormulaR1C1 = "=СУММ(R[-" +( tbl_rez.Rows.Count-1).ToString() + "]C:R[-1]C)";
        // In English
        //cellWithFormulaR1C1.FormulaR1C1 = "=SUM(R[-" + (tbl_rez.Rows.Count - 1).ToString() + "]C:R[-1]C)";

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>