Пример #1
0
        public void Test2()
        {
            var fn = Path.Combine(Globals.TestDataPath, "hdb_report.xls");

            NpoiExcel xls = new NpoiExcel(fn);


            xls.SetCellText(0, "D7", "oracle.service.name");
            xls.SetCellText(0, "D8", DateTime.Now.ToString());
            var tbl = CreateTestTable(4);

            xls.InsertDataTable(0, "A9", tbl);


            int    lastRow  = 10 + tbl.Rows.Count;
            string strRange = "A10:A" + (lastRow + 5);

            // CellStyle

            xls.FormatRange(0, "B10:B12", "0.00");
            xls.FormatRange(0, "C10:C13", "0.0");
            xls.FormatRange(0, "D10:D14", "0");


            string[] formats = new string[] { "", "" };
//           IRange rng= ws.Cells[strRange];
//           rng = rng.Offset(0, 1);
//           for (int i = 0; i < formats.Length; i++)
//           {
//               rng.NumberFormat = ExcelFormat(formats[i]);
//               rng = rng.Offset(0, 1);
//           }

            string fnk = FileUtility.GetTempFileName(".xls");// @"c:\temp\karl.xls";

            xls.Save(fnk);
            //System.Diagnostics.Process.Start(fnk);
        }
Пример #2
0
        public void PrintPreview()
        {
            NpoiExcel xls = new NpoiExcel(xlsFilename);

            xls.SetCellText(0, "D7", Hdb.Instance.Server.ServiceName);
            xls.SetCellText(0, "D8", DateTime.Now.ToString());

            xls.InsertDataTable(0, "A9", msDataTable);
            // format excel according to POET format.

            for (int c = 1; c < msDataTable.DisplayFormat.Length; c++)
            {
                string fmt = ExcelFormat(msDataTable.DisplayFormat[c]);
                xls.FormatRange(0, 10, c, msDataTable.Rows.Count + 10, c, fmt);
            }

            xls.Save(xlsFilename);
            System.Diagnostics.Process.Start(xlsFilename);
        }