C #을 사용하여 Excel 파일을 읽는 동안 한 가지 문제가 있습니다. 내 Excel 파일에서 DateTime 인 하나의 열과 Excel 파일의 값이 깁니다. 따라서 Excel은 C #에서 동일한 값을 사용하여 동일한 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);
}
이렇게 시도하십시오 :-
var conv = DateTime.FromOADate("B"+i);
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다