1
这是我的第一个AddIn excel,并且我在使用分隔符(“|”)导出文本文件中的excel文件时遇到了问题。 我想导出excel的文件在相同的路径,扩展名为“.txt”,我想用特定字符(“|”)分隔excel的列。C#AddIn Excel:导出带分隔符的文本文件中的xls文件
我创建功能区上的一个按钮:
private void exportSave_Click(object sender, RibbonControlEventArgs e)
{
int lastColumns;
lastColumns = usedRange.Columns.Count;
int endCol = lastColumns;
Microsoft.Office.Interop.Excel.Worksheet xlSheet = Globals.VATTools.Application.ActiveSheet;
Microsoft.Office.Interop.Excel.Range usedRange = xlSheet.UsedRange;
// Save file in .txt in the same path
string path = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
xlSheet.SaveAs(path, Microsoft.Office.Interop.Excel.XlFileFormat.xlTextWindows);
}
我不知道格式“xlTextWindows”的。
我确定我的专栏,但我不知道如何将其导出为.txt
由于之前加列之间的特定字符!
谢谢,这是完美的! – user2814368