Beispiel #1
0
 private void LoadRows(XlWorksheet worksheet, LoadRow loadRow)
 {
     for (int index = 1; index < worksheet.Rows.Count; index++)
     {
         var values = worksheet.ValueRow(index);
         if (values.Count > 0)
         {
             // Skip empty rows
             foreach (String cur in values.Values)
             {
                 if (!string.IsNullOrEmpty(cur))
                 {
                     loadRow(worksheet.Name, values); //we got at least one non-empty cell
                     break;
                 }
             }
         }
     }
 }
Beispiel #2
0
        private static void PrintWorksheet(XlWorksheet worksheet)
        {
            int   rowIndex = 1;
            Color color    = Color.FromArgb(worksheet.TabColor.ArgbColor);

            Console.WriteLine("Worksheet Name: {0}, Color: {1}, Position: {2}", worksheet.Name, color, worksheet.Position);
            foreach (XlColumn cur in worksheet.Columns)
            {
                Console.Write(cur.Name + ", ");
            }
            Console.WriteLine();
            foreach (IXlRowData row in worksheet.Rows)
            {
                int columnIndex = 1;
                PrintRow(worksheet.ValueRow(rowIndex - 1));
                //foreach (IXlCell cell in row)
                //{
                //    Console.WriteLine("Row: {3}, Col: {4}, Cell Value: {0}, Type: {1}, Style: {2}", cell.CellValue, cell.CellType, cell.CellStyle, rowIndex, columnIndex++);
                //}
                rowIndex++;
            }
        }