Exemple #1
0
        static void Main(string[] args)
        {
            IExcelPlugin excel    = new ExcelPlugin();
            var          workbook = excel.CreateExcel();
            var          sheet    = excel.CreateSheet(workbook, "sheet1");

            sheet = excel.CreateSheet(workbook, "sheet1");
            sheet = excel.CreateSheet(workbook, "sheet1");
            sheet = excel.CreateSheet(workbook, "sheet1");

            //测试1

            string json = @"['Small','Medium','Large']";
            JArray data = JArray.Parse(json);
            var    ok   = excel.WriteRow(sheet, 0, 1, data);

            //测试2

            var sheet2 = excel.CreateSheet(workbook, "sheet2");

            json = @"[['Small','Medium','Large'],['Small','Medium','Large']]";
            data = JArray.Parse(json);
            ok   = excel.WriteRange(sheet2, 0, 0, data);

            ok = excel.Save(workbook, @"C:\Users\Joey\Desktop\百度疫情迁徙数据\山东.xlsx");
            Console.WriteLine("保存结果:{0}", ok);

            Console.ReadLine();
        }
        public void TestWriteCell()
        {
            IExcelPlugin excel    = new ExcelPlugin();
            var          workbook = excel.CreateExcel();
            var          sheet    = excel.CreateSheet(workbook, "shee1");
            var          result   = excel.WriteCell(sheet, 0, 1, "name");

            result = excel.WriteCell(sheet, 1, 1, 1);
            result = excel.WriteCell(sheet, 2, 1, 23.90);
            result = excel.WriteCell(sheet, 3, 1, 3999999999.00000003);

            if (result)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.IsTrue(false);
            }

            excel.Save(workbook, "");
        }