1
DocumentFormat.openxml nuget pkgを使用して.xlsxファイルを読み込んでいます。私は、日付セルを読みしようとしています[G2]からのデータ[B5]に[M5]openxmlを使用してExcelファイルのセルデータを読み取る方法
私はあなたがこれを行うことができ、細胞によって行ごと、その後、セルを移動したい
static void Main(string[] args)
{
string sFileTypeError = string.Empty;
string myFilePath = @"C:\Landing\file.xlsx";
//string ext = Path.GetExtension(myFilePath);
var fileName = Path.GetFileName(myFilePath);
var fileExtension = Path.GetExtension(fileName);
if ((fileExtension != ".xlsx") && (fileExtension != ".xls"))
sFileTypeError = "Invalid file. \n\nPlease browse a correct Excel file to upload.";
else
{
using (SpreadsheetDocument doc = SpreadsheetDocument.Open(myFilePath, false))
{
IEnumerable<Sheet> sheets = doc.WorkbookPart.Workbook.GetFirstChild<DocumentFormat.OpenXml.Spreadsheet.Sheets>().Elements<Sheet>();
WorksheetPart worksheetPart = (WorksheetPart)doc.WorkbookPart.GetPartById(sheets.First().Id.Value);
IEnumerable<Row> rows = worksheetPart.Worksheet.GetFirstChild<SheetData>().Descendants<Row>();
}
}
}
Please let me know how can read this. Thanks