コード例 #1
0
            public static void PopulateInCollection(string filename, string sheetName)
            {
                ExcelOperations.ClearData();
                DataTable table = ExcelToDataTable(filename, sheetName);

                for (int row = 1; row <= table.Rows.Count; row++)
                {
                    for (int col = 0; col < table.Columns.Count; col++)
                    {
                        DataCollection dtTable = new DataCollection()
                        {
                            rowNumber = row,
                            colName   = table.Columns[col].ColumnName,
                            colValue  = table.Rows[row - 1][col].ToString()
                        };
                        dataCol.Add(dtTable);
                    }
                }
            }