简体   繁体   English

使用Microsoft.Office.Interop.Excel在文本文件中处理Excel错误的日期

[英]Excel bug handling dates in Text files using Microsoft.Office.Interop.Excel

So I upload Excel file then save it as Text file but I have problem with date format. 所以我上传Excel文件,然后将其另存为文本文件,但是日期格式有问题。

My excel the date format is dd/MM/yyyy but when I save it as Text File its format is MM/dd/yyyy 我的excel日期格式为dd / MM / yyyy,但是当我将其保存为文本文件时,其格式为MM / dd / yyyy

Imports Microsoft.Office.Interop



Dim FileName As String = "C:\myExcelData.txt"
Dim xl As New Excel.Application
Dim xlBook As Excel.Workbook = xl.Workbooks.Open("C:\myExcel.xlsx")

Dim xlSheet As Excel.Worksheet = xlBook.Sheets("Sheet1")
xl.DisplayAlerts = False
xlSheet.SaveAs(FileName, Excel.XlFileFormat.xlTextWindows)
xlBook.Close()

In myExcel.xlsx Date is 31/01/2014 在myExcel.xlsx中,日期为2014年1月31日

In myExcelData.txt Date is 1/31/2014 在myExcelData.txt中日期为1/31/2014

尝试添加最后一个参数Local:=True

xlSheet.SaveAs(Filename:=FileName, FileFormat:=Excel.XlFileFormat.xlTextWindows,Local:=True)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Microsoft.Office.Interop.Excel的Excel dll - Excel dll for Microsoft.Office.Interop.Excel 如何在 C# 中使用 Microsoft.Office.Interop.Excel 在 Excel 中的矩形内写入文本 - How to write a text inside a rectangle in excel using Microsoft.Office.Interop.Excel in c# 导入Microsoft.Office.Interop.Excel命名空间 - Importing the Microsoft.Office.Interop.Excel namespace 如何使用C#,Microsoft.Office.Interop.Excel格式化Excel文本框以更改字体样式,大小,名称 - How to format the text box of excel to change the font style,size,name using c#,Microsoft.Office.Interop.Excel 使用Microsoft.Office.Interop.Excel导出到asp.net中的excel - Export to excel in asp.net using Microsoft.Office.Interop.Excel 将数据表导出到Excel后使用Microsoft.office.interop.Excel日期格式问题 - Using Microsoft.office.interop.Excel Date format issue after exporting Data Table To Excel 程序集“ Microsoft.Office.Interop.Excel”中的“ Microsoft.Office.Interop.Excel.WorkbookClass”未标记为可序列化 - Microsoft.Office.Interop.Excel.WorkbookClass' in Assembly 'Microsoft.Office.Interop.Excel, is not marked as serializable Microsoft.Office.Interop.Excel不适用于64位 - Microsoft.Office.Interop.Excel doesn't work on 64 bit 如何保存由Microsoft.Office.Interop.Excel生成的文件 - How To Save a File Generated by Microsoft.Office.Interop.Excel 如果我使用的是Microsoft.Office.Interop.Excel,如何在客户端PC中保存xsl文件 - how to save xsl file in client pc if i am using Microsoft.Office.Interop.Excel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM