Opening .dat (tab delimited file) in Excel, save as .xls

前端 未结 4 1571
无人及你
无人及你 2021-01-14 16:39

I am trying to open a .dat file in Excel, which is tab delimited, and then have it save out as a .xls file.

So far, I can read in the file and save it as the .xls fi

4条回答
  •  北海茫月
    2021-01-14 17:29

    The fix for this question:

    xlWorkBook = xlApp.Workbooks.Open(f, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); xlWorkBook.SaveAs(filename + ".xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);

    In the xlApp.Worksbooks.Open() method, the fourth arg is "Format" which if you use the value '1', it will assume that the file is tab delimited and open it accordingly.

提交回复
热议问题