コード例 #1
0
        public SampleOne()
        {
            InitializeComponent();

            if (File.Exists("sampleone.xls"))
            {
                try
                {
                    ModelOne[] list;
                    using (var factory = new ObjectFactory("sampleone.xls"))
                    {
                        list = factory.SheetToObjects <ModelOne>();
                        dataGridView1.DataSource = list;
                    }
                    using (var factory = new DrawingFactory(string.Format("{0}.xlsx", DateTime.Now.ToFileTimeUtc())))
                    {
                        factory.Draw(0, "Sheet0", list);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }
            }
            else
            {
                MessageBox.Show("no find sampleone.xls file.");
            }
        }
コード例 #2
0
 public FormSample()
 {
     InitializeComponent();
     TestModel[] locationList;
     using (var factory = new ObjectFactory("input.xls"))
     {
         locationList = factory.SheetToObjects<TestModel>();
         dataGridView1.DataSource = locationList;
     }
     using (var factory = new DrawingFactory(string.Format("{0}.xls", DateTime.Now.ToFileTimeUtc())))
     {
         factory.Draw(0, "Sheet0", locationList);
     }
 }