Example #1
0
        public void test()
        {
            var testDataModel = new TestDataModel()
            {
                GooodsCode = "11111",
                NameCN     = "",
                NameEN     = "NameEN",
                NameJP     = "NameJP",
                NameKOR    = "NameKOR"
            };

            var testDataModel2 = new TestDataModel()
            {
                GooodsCode = "22222",
                NameCN     = "NameCN2",
                NameEN     = "",
                NameJP     = "NameJP2",
                NameKOR    = "NameKOR2"
            };

            var testDataModel3 = new TestDataModel()
            {
                GooodsCode = "33333",
                NameCN     = "NameCN2",
                NameEN     = "NameEN2",
                NameJP     = "",
                NameKOR    = "NameKOR2"
            };

            var testDataModel4 = new TestDataModel()
            {
                GooodsCode = "44444",
                NameCN     = "NameCN2",
                NameEN     = "",
                NameJP     = "NameJP2",
                NameKOR    = ""
            };

            var testDataModel5 = new TestDataModel()
            {
                GooodsCode = "",
                NameCN     = "NameCN2",
                NameEN     = "",
                NameJP     = "NameJP2",
                NameKOR    = ""
            };

            var dataList = new List <TestDataModel>();

            dataList.Add(testDataModel);
            dataList.Add(testDataModel2);
            dataList.Add(testDataModel3);
            dataList.Add(testDataModel4);
            dataList.Add(testDataModel5);

            var excel      = new ToExcel();
            var streamData = excel.DataToExcel <List <TestDataModel> >(dataList, "공백테스트");

            System.IO.File.WriteAllBytes(@"C:\Users\ronal\Desktop\excel\test.xlsx", streamData);
        }
Example #2
0
        public void GetExcel()
        {
            FromExcel e = new FromExcel();
            //var dt = e.OpenExcel(@"C:\Users\ronal\Desktop\excel\GoodsCode_2018_04_26_033012.xlsx");
            //var dt = e.OpenExcel(@"C:\Users\ronal\Desktop\test상품명수집_2018_05_10_155618.xlsx");

            string err = string.Empty;
            //var dt = e.OpenExcel(@"C:\Users\ronal\Desktop\test상품명수집_2018_05_10_155618.xlsx", ref err);
            //var dt = e.OpenExcel(@"C:\Users\ronal\Desktop\미동의테스트.xlsx");
            var dt = e.OpenExcel(@"C:\Users\ronal\Desktop\공백테스트 - 복사본.xlsx", ref err);


            ;
            List <TestDataModel> model = new List <TestDataModel>();

            foreach (DataRow row in dt.Rows)
            {
                TestDataModel t = new TestDataModel()
                {
                    GooodsCode = row[0].ToString(),
                    NameCN     = row[1].ToString(),
                    NameEN     = row[2].ToString(),
                    NameJP     = row[3].ToString(),
                    NameKOR    = row[4].ToString()
                };
                model.Add(t);
            }

            ;
        }