0
我需要從xls文件中的特定列中提取行數據,並在迭代時將每行添加到列表中。我看了這個網站,發現How to iterate through Excel Worksheets only extracting data from specific columns,但我不知道如何修改,以允許在經歷每次迭代時添加到列表。如何通過Excel迭代只從特定列中提取數據
Excel.Application xlApp = new Excel.Application();
Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(@"C:\Temp\Sample\Sample.xls");
Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
Excel.Range xlRange = xlWorksheet.UsedRange;
int rowCount = xlRange.Rows.Count;
int colCount = xlRange.Columns.Count;
for (int i = 1; i <= rowCount; i++)
{
for (int j = 1; j <= colCount; j++)
{
//Not sure if I need to iterate this way or not
}
}
你能可能顯示'Sample.xls',準確地解釋你」重新嘗試提取? – soumer
我不知道如何添加示例文件。它看起來像:(第一行是標題) (第一行)日期組別說明代理 (Line 2)11/07/2016 1 Pessoa Fisica 1306 –