using ClosedXML.Excel;
namespace Service
{
internal class ImportExcel
{
public void ImportMyExcel(string filename)
{
try
{
// 読み込み専用で開く
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
XLWorkbook workbook = new XLWorkbook(fs);
IXLWorksheet worksheet = workbook.Worksheet(1);
IXLCell cell;
int i = 1;
while (true)
{
cell = worksheet.Cell(i, 1);
if (String.IsNullOrEmpty(cell.Value.ToString())) break;
// TODO:業務ロジック
i++;
}
}
catch
{
throw (new AppBaseException("Error:Read excel file. : " + filename));
}
}
}
}
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme