コード例 #1
0
        private void TryOpenExcel(string name)
        {
            ExcelOperator excel = new ExcelOperator();

            excel.OpenExcel(name);
            int idxRow = 2;

            while (true)
            {
                Range test = excel[idxRow, 1];
                if (test.Value2 == null)
                {
                    break;
                }
                else
                {
                    idxRow++;
                }
            }
            int cnt = idxRow;
            Form_ImportProgress fip = new Form_ImportProgress(cnt - 2);

            fip.Show();
            for (idxRow = 2; idxRow < cnt; idxRow++)
            {
                Range    range = excel[idxRow, 1];
                string[] raw1  = new string[6];
                for (int idxColumn = 1; idxColumn <= 6; idxColumn++)
                {
                    Range cell = excel[idxRow, idxColumn];
                    raw1[idxColumn - 1] = cell.Value2;
                }
                if (BookList.isExist(raw1[0], raw1[1], raw1[3]))
                {
                    continue;
                }
                string[] raw2 = new string[6];
                int      word = (int)Math.Round(excel[idxRow, 7].Value2);
                raw2[0] = word.ToString();
                for (int idxColumn = 8; idxColumn <= 12; idxColumn++)
                {
                    Range cell = excel[idxRow, idxColumn];
                    raw2[idxColumn - 7] = (string)cell.Value2;
                }
                BookDetail item = new BookDetail(0, raw1, raw2);
                BookList.Add(BookList.getNextBID(), item);
                // ProgressBar
                fip.ChangeTo(idxRow - 1);
            }
            excel.QuitExcel();
            fip.Close();
        }
コード例 #2
0
ファイル: Form_Main.cs プロジェクト: cfrpg/Publish
 private void TryOpenExcel(string name)
 {
     ExcelOperator excel = new ExcelOperator();
     excel.OpenExcel(name);
     int idxRow = 2;
     while (true)
     {
         Range test = excel[idxRow, 1];
         if (test.Value2 == null) break;
         else idxRow++;
     }
     int cnt = idxRow;
     Form_ImportProgress fip = new Form_ImportProgress(cnt - 2);
     fip.Show();
     for (idxRow = 2; idxRow < cnt; idxRow++ )
     {
         Range range = excel[idxRow, 1];
         string[] raw1 = new string[6];
         for (int idxColumn = 1; idxColumn <= 6; idxColumn++)
         {
             Range cell = excel[idxRow, idxColumn];
             raw1[idxColumn - 1] = cell.Value2;
         }
         if (BookList.isExist(raw1[0], raw1[1], raw1[3])) continue;
         string[] raw2 = new string[6];
         int word = (int)Math.Round(excel[idxRow, 7].Value2);
         raw2[0] = word.ToString();
         for (int idxColumn = 8; idxColumn <= 12; idxColumn++)
         {
             Range cell = excel[idxRow, idxColumn];
             raw2[idxColumn - 7] = (string)cell.Value2;
         }
         BookDetail item = new BookDetail(0, raw1, raw2);
         BookList.Add(BookList.getNextBID(), item);
         // ProgressBar
         fip.ChangeTo(idxRow - 1);
     }
     excel.QuitExcel();
     fip.Close();
 }