在Excel中打开.dat(制表符分隔的文件),另存为.xls [英] Opening .dat (tab delimited file) in Excel, save as .xls

查看:518
本文介绍了在Excel中打开.dat(制表符分隔的文件),另存为.xls的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Excel中打开一个.dat文件,该文件用制表符分隔,然后将其另存为.xls文件。

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

到目前为止,我可以读入文件并将其另存为.xls文件,但是由于某些原因,所有值都在第一列中,并且它不能用Tab键分隔它们。

So far, I can read in the file and save it as the .xls file but for some reason, all the values are in the first column and it does not tab delimit them.

(如果我在不使用程序的情况下在Excel中打开文件,则它会以Tab键定界)

(If I open up the file in Excel without my program, it tab-delimits perfectly)

这是我用来打开和重新保存代码的两行代码

These are the two lines of code that I am using to open and resave the file.

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);


推荐答案

此问题的解决方法:


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

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);

在xlApp.Worksbooks.Open()方法中,第四个参数为格式,如果您使用值'1',则将假定文件以制表符分隔并相应打开。

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.

这篇关于在Excel中打开.dat(制表符分隔的文件),另存为.xls的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆