我的代码会产生这样的如何格式化使用C#在Excel/CSV标题
|id | Name | Address | company_Name | Destination|
|----|-------|----------|--------------|------------|
|##1 | xxx | xxxx | xxx | xxxxx |
Excel文档,但我想是这样的...
-----------------------------------------------------
| Personal Information | Working INFO |
-----------------------------------------------------
|id | Name | Address | company_Name | Destination|
|----|-------|----------|--------------|------------|
|##1 | xxx | xxxx | xxx | xxxxx |
-----------------------------------------------------
我从数据API和我将使用它保存它SaveFileDialog
SaveFileDialog dialog = new SaveFileDialog();
dialog.Title = "Save file as...";
dialog.Filter = "Text files (*.csv)|*.csv";
dialog.RestoreDirectory = true;
if (dialog.ShowDialog() == DialogResult.OK)
{
System.IO.StreamWriter writer = new System.IO.StreamWriter(dialog.FileName); //open the file for writing.
writer.Write(report); //write the current date to the file. change this with your date or something.
writer.Close(); //remember to close the file again.
writer.Dispose(); //remember to dispose it from the memory.
program.ShowInformationMessage("File Save successfully");
}
它没有问题。
我想使标题为内联的东西。
你知道为什么你是从别人收到downvote?由于这个原因:“你写的代码的问题必须在问题本身中描述具体问题 - 并包含有效的代码以再现它。”所以,展示你现在拥有的东西。 –
你在使用Interop吗?如果是,请参阅[这](http://www.siddharthrout.com/vb-dot-net-and-excel/)检查“合并/取消合并单元格”部分代码在vb中。净,但可以轻松移植到C# –
忽略我上面的评论。我刚看到你的编辑。 –