C# を使用して Excel ファイルを読み取るときに問題が 1 つあります。私のExcelファイルでは、DateTimeの列が1つあり、Excelファイルの値は長いです。そのため、C# で同じ値を取得して C# を使用して同じ Excel を読み取ると、Excel はそれを ###### 形式に変換します。誰でも助けてください: ##### の代わりに日時の値を取得するにはどうすればよいですか?
私のコードは次のようになります:
using Excel = Microsoft.Office.Interop.Excel;
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
ExcelObj = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook theWorkbook = ExcelObj.Workbooks.Open(oldg.FileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
Microsoft.Office.Interop.Excel.Sheets sheets = theWorkbook.Worksheets;
Microsoft.Office.Interop.Excel.Worksheet worksheet = (Microsoft.Office.Interop.Excel.Worksheet)sheets.get_Item(1);
for (int i = 3; i <= worksheet.UsedRange.Rows.Count; i++)
{
var getvalue = excel_getValue("B" + i);
}