Merge mutliple擅长于一张具有一张纸的excel [英] Merge mutliple excels into a single excel having one sheet

查看:59
本文介绍了Merge mutliple擅长于一张具有一张纸的excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,我在文件夹中保留多个excel。每个excel只有一张。我需要将这些合并为一个。



例如,



Excel 1有表1带标题

标题1标题2标题3



和数据

1 2 3

11 22 33





Excel 2 woth表1含有内容

Header 1 Header 4 Header 5

33 44 55

66 77 88



我需要一张新的Excel,一张和数据为关注



标题1标题2标题3标题4标题5

1 2 3

11 22 33

33 44 55

66 77 88



我尝试了以下链接中的一个代码





http://bembengarifin.wordpress.com/2010/11/02/combine-multiple-ex cel-files-into-one-with-c / [ ^ ]



它提供的单个文件包含两张包含数据的文件sheet1中的excel1和表2中的excel 2

I have an application where i'm keeping multiple excels in a folder. Each excel will have only one sheet. I need to merge these together to single one.

For eg,

Excel 1 having sheet 1 with Header
Header 1 Header 2 Header 3

And data
1 2 3
11 22 33


Excel 2 woth sheet 1 having content
Header 1 Header 4 Header 5
33 44 55
66 77 88

I need a new excel with one sheet and data as follows

Header 1 header 2 Header 3 Header 4 Header 5
1 2 3
11 22 33
33 44 55
66 77 88

I tried one code from the below link


http://bembengarifin.wordpress.com/2010/11/02/combine-multiple-excel-files-into-one-with-c/[^]

It is giving single file with two sheets having data of excel1 in sheet1 and excel 2 in sheet 2

推荐答案

将Excel工作表数据读入DataTable [ ^ ]



http://social.msdn.microsoft.com/Forums / vstudio / en-US / 45141eb3-9010-455c-a095-e4f4f709ca08 / function-to-import-excel-data-to-dataset-in- [ ^ ]



从这种方式你可以选择两个diff excel成一个然后写入excel或合并到一个dt然后填写excel

问候....:)



更新



https://www.google.co.in/search?sclient=psy-ab&q=wirte+dt+to + excel + c%23& btnG = [ ^ ]
Read Excel Sheet Data into DataTable[^]

http://social.msdn.microsoft.com/Forums/vstudio/en-US/45141eb3-9010-455c-a095-e4f4f709ca08/function-to-import-excel-data-to-dataset-in-[^]

from this way you can select two diff excels into one and then write to excel or merge in to one dt then fill the excel
regards....:)

updated

https://www.google.co.in/search?sclient=psy-ab&q=wirte+dt+to+excel+c%23&btnG=[^]


我尝试使用以下代码从datatable写入excel



I tried the below code to write from datatable to excel

string filename = "Reconciliation_Result.xls";
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
DataGrid dgGrid = new DataGrid();
dgGrid.DataSource = dt;
dgGrid.DataBind();

//Get the HTML for the control.
dgGrid.RenderControl(hw);
//Write the HTML back to the browser.

Response.ContentType = "application/ms-excel";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename + "");
Response.Charset = "utf-8";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250");
Response.Write("<Table border='1' bgColor='#ffffff' " +      "borderColor='#000000' cellSpacing='0' cellPadding='0' " +      "style='font-size:10.0pt; font-family:Calibri; background:white;'> <TR>");
this.EnableViewState = true;
Response.Write(tw.ToString());
Response.End();





它正在工作..但excel的第二列我需要将第二列格式化为文本..任何人都可以帮忙吗?



it is working ..but the second column of the excel i need to format the second column as text ..can anyone help?


避免将数据从datagrid导出到excel时的默认格式。 [ ^ ]


这篇关于Merge mutliple擅长于一张具有一张纸的excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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