예제 #1
0
        public void TestFill_1()
        {
            Student stu = new Student {
                ClassName = "软件研发部", Name = "库管员", Birthday = DateTime.Today, Name2 = "测试人员"
            };
            List <Grade> gradeList = new List <Grade> {
                new Grade {
                    Name = "DVD光盘", Brand = "紫光", UnitName = "个", Quantity = 10, Price = 5.0
                }, new Grade {
                    Name = "计算机", Brand = "Dell", UnitName = "台", Quantity = 1, Price = 5000.0
                },
                new Grade {
                    Name = "硬盘", Brand = "华硕", Spec = "2T", UnitName = "个", Quantity = 1, Price = 600.0
                }, new Grade {
                    Name = "液晶显示器", Brand = "Dell", Spec = "21寸宽屏", UnitName = "台", Quantity = 1, Price = 2000.0
                }
            };

            stu.Total = gradeList.Sum(g => g.Quantity * g.Price);

            ExportWrapper.FillExcel <Grade, List <Grade>, Student>(configFile, tableId, "1", AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\') + "\\Excel\\fill.xls", AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\') + "\\Excel\\fill1.xls", gradeList, stu);
            ExportWrapper.FillExcel <Grade, List <Grade>, Student>(configFile, tableId, "1", AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\') + "\\Excel\\fill.xlsx", AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\') + "\\Excel\\fill1.xlsx", gradeList, stu);

            ExportWrapper.ExportCSV <Grade, List <Grade> >(configFile, tableId, "3", AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\') + "\\Excel\\csv1.csv", gradeList);
        }
예제 #2
0
        public void TestExport_1()
        {
            List <Grade> gradeList = new List <Grade> {
                new Grade {
                    ClassId = "一班", StudentId = "1", Html = 60
                }, new Grade {
                    ClassId = "二班", StudentId = "1", Java = 70
                }
            };

            ExportWrapper.ExportExcel <Grade, List <Grade> >(configFile, tableId, "2", AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\') + "\\Excel\\export.xls", gradeList,
                                                             tableHeaderWriter: CustomTableHeader, tableFooterWriter: CustomTableFooter);
            ExportWrapper.ExportExcel <Grade, List <Grade> >(configFile, tableId, "3", AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\') + "\\Excel\\export.xlsx", gradeList,
                                                             tableHeaderWriter: CustomTableHeader, tableFooterWriter: CustomTableFooter);
        }
예제 #3
0
    /// <summary>
    /// 初始化
    /// </summary>
    public void Init()
    {
        string appPath = Application.StartupPath;

        LastOpenExcelPath = appPath;

        for (int i = 1; i < ClientExportInfos.Length; i++)
        {
            ClientExportInfos[i]            = new ExportWrapper();
            ClientExportInfos[i].ExportPath = appPath;
        }

        for (int i = 1; i < ServerExportInfos.Length; i++)
        {
            ServerExportInfos[i]            = new ExportWrapper();
            ServerExportInfos[i].ExportPath = appPath;
        }

        for (int i = 1; i < BattleExportInfos.Length; i++)
        {
            BattleExportInfos[i]            = new ExportWrapper();
            BattleExportInfos[i].ExportPath = appPath;
        }
    }
    /// <summary>
    /// 初始化
    /// </summary>
    public void Init()
    {
        string appPath = Directory.GetCurrentDirectory();

        ExcelPath = Path.Combine(appPath, "../Excel/");

        ClientExportInfo = new ExportWrapper();
        ClientExportInfo.ExporterType = typeof(CsExporter);
        ClientExportInfo.ExportPath   = Path.Combine(appPath, "../Client/Assets/GameScript/Runtime/Config/AutoGenerateConfig");
        if (Directory.Exists(ClientExportInfo.ExportPath))
        {
            Directory.Delete(ClientExportInfo.ExportPath, true);
        }
        Directory.CreateDirectory(ClientExportInfo.ExportPath);

        ClientExportConfigInfo = new ExportWrapper();
        ClientExportConfigInfo.ExporterType = typeof(BytesExporter);
        ClientExportConfigInfo.ExportPath   = Path.Combine(appPath, "../Client/Assets/GameRes/Config");
        if (Directory.Exists(ClientExportConfigInfo.ExportPath))
        {
            Directory.Delete(ClientExportConfigInfo.ExportPath, true);
        }
        Directory.CreateDirectory(ClientExportConfigInfo.ExportPath);
    }