コード例 #1
0
ファイル: UserControl7.cs プロジェクト: Hotrak/My-Projects
        private void button2_Click(object sender, EventArgs e)
        {
            List <List <string> > list = new List <List <string> >();

            ListView listView;

            if (listView1.Visible)
            {
                listView = listView1;
            }
            else
            {
                listView = listView2;
            }


            for (int i = 0; i < listView.Items.Count; i++)
            {
                list.Add(new List <string>());
                for (int j = 0; j < listView.Items[i].SubItems.Count; j++)
                {
                    list[i].Add(listView.Items[i].SubItems[j].Text);
                }
            }

            //Exele ex = new Exele("d:/ex1.xlsx", 1);

            ////string data
            //ex.StatistickExportModals(comboBox2.Text +" " + comboBox3.Text, list);

            //ex.SaveAs(@"C:\Users\User\Desktop\легчайшый тест\ex2.xlsx");
            //ex.Close();
            //System.Diagnostics.Process.Start(@"C:/Users/User/Desktop/легчайшый тест/ex2.xlsx");

            SaveFileDialog saveFileDialog1 = new SaveFileDialog
            {
                Filter       = "Excel Files|*.xls;*.xlsx;*.xlsm",
                DefaultExt   = "xlsx",
                AddExtension = true
            };

            if (saveFileDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            string filename = saveFileDialog1.FileName;

            Exele ex = new Exele();

            ex.CreateNewFile();
            ex.StatistickExportModals(comboBox2.Text + " " + comboBox3.Text, list);
            ex.SaveAs(filename);
            ex.Close();
            System.Diagnostics.Process.Start(filename);
        }
コード例 #2
0
ファイル: Form11.cs プロジェクト: Hotrak/My-Projects
        private void Export()
        {
            List <List <string> > list = new List <List <string> >();

            for (int i = 0; i < listView1.Items.Count; i++)
            {
                if (int.Parse(listView1.Items[i].SubItems[4].Text) != 0)
                {
                    list.Add(new List <string>());
                    for (int j = 1; j < listView1.Items[i].SubItems.Count; j++)
                    {
                        if (j != 3)
                        {
                            list[list.Count - 1].Add(listView1.Items[i].SubItems[j].Text);
                        }
                    }
                }
            }

            SaveFileDialog saveFileDialog1 = new SaveFileDialog
            {
                Filter       = "Excel Files|*.xls;*.xlsx;*.xlsm",
                DefaultExt   = "xlsx",
                AddExtension = true
            };

            if (saveFileDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            string filename = saveFileDialog1.FileName;

            Exele ex = new Exele();

            ex.CreateNewFile();

            ex.ExportOstatki(list);
            ex.SaveAs(filename);
            ex.Close();
            System.Diagnostics.Process.Start(filename);
        }
コード例 #3
0
ファイル: UserControl4.cs プロジェクト: Hotrak/My-Projects
        private void Export(int idOdrer, string data)
        {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog
            {
                Filter       = "Excel Files|*.xls;*.xlsx;*.xlsm",
                DefaultExt   = "xlsx",
                AddExtension = true
            };

            if (saveFileDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            string filename = saveFileDialog1.FileName;

            Exele ex = new Exele();

            ex.CreateNewFile();
            ex.WriteToCell(idOdrer, data, Form5.skidka);
            ex.SaveAs(filename);
            ex.Close();
            System.Diagnostics.Process.Start(filename);
        }