如何在现有excel模板中的aspose单元格上打开excel工作表,并使用带有c#的asp.net在现有excel模板上编写新的excel工作表 [英] How to open excel worksheet on aspose cell in existing excel template and write new excel worksheets on existing excel template using asp.net with c#

查看:70
本文介绍了如何在现有excel模板中的aspose单元格上打开excel工作表,并使用带有c#的asp.net在现有excel模板上编写新的excel工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

如何在现有excel模板中的aspose单元格上打开excel工作表,并使用带有c#的asp.net在现有excel模板上编写新的excel工作表?



谢谢和问候,

Parthiban K.

解决方案

如果我理解你的要求,你想要的使用Aspose将新工作表添加到Excel文档中?



  var  workbook =  new 工作簿(  C:\\\ \\Project\\Test.xlsx); 
workbook.Worksheets.Add( 新工作表);

var newWorksheet = workbook.Worksheets [ 新工作表];
// 从这一点开始,您可以使用新工作表执行所需操作

workbook.Save( C:\\Project \\New.xlsx ,SaveFormat.Xlsx);


亲爱的朋友们,



我发现了正确回答这个问题,这里代码:



.aspx.cs







  public   void  AllTabExport(DataTable dt, String  sheetname)
{
string jobno = ddlno。 SelectedItem.Text;
string jobrevno = ddlRevNo.SelectedItem.Text;
Aspose.Cells.License Lic = new Aspose.Cells.License();
Lic.SetLicense( Aspose.Cells.lic);
// 实例化新工作簿
工作簿工作簿= new Workbook();
workbook.Worksheets.Clear();
// 添加新工作表数据;
workbook.Open( Server.MapPath( )+ @ \ Report \ Model-Template.xls);
工作表工作表= workbook.Worksheets.Add( GAD_Model_Template);
DataRow dr = dt.NewRow();
dt.Rows.Add(dr);
worksheet.Cells.ImportDataTable(dt, true A1);
workbook.Save(Server.MapPath( )+ @ \ Report \ GAD_Model_Template _ + Convert.ToString(Session [ UID])+ _ + jobno + _ + jobrevno + 。xls);
ScriptManager.RegisterStartupScript( this ,GetType(), alert('数据已成功过期'); true );
}





感谢您的亲切协调微笑!







谢谢和问候,



Parthiban K。


使用免费的Opensource EPPlus库。



http://epplus.codeplex.com



您定位的.net框架的哪个版本?

Dear frnds,
How to open excel worksheet on aspose cell in existing excel template and write new excel worksheets on existing excel template using asp.net with c#?

Thanks and regards,
Parthiban K.

解决方案

If I understand what you are asking, you want to add a new worksheet to an Excel document using Aspose?

var workbook = new Workbook("C:\\Project\\Test.xlsx");
workbook.Worksheets.Add("New Worksheet");

var newWorksheet = workbook.Worksheets["New Worksheet"];
//From this point you can do what you need too with the new worksheet

workbook.Save("C:\\Project\\New.xlsx", SaveFormat.Xlsx);


Dear frnds,

I found the correct answer to this question, here that code:

.aspx.cs



public void AllTabExport(DataTable dt, String sheetname)
    {
        string jobno = ddlno.SelectedItem.Text;
        string jobrevno = ddlRevNo.SelectedItem.Text;
        Aspose.Cells.License Lic = new Aspose.Cells.License();
        Lic.SetLicense("Aspose.Cells.lic");
        //Instantiate a new Workbook
        Workbook workbook = new Workbook();
        workbook.Worksheets.Clear();
        //Add a new Sheet "Data";
        workbook.Open(Server.MapPath(".") + @"\Report\Model-Template.xls");
        Worksheet worksheet = workbook.Worksheets.Add("GAD_Model_Template");
        DataRow dr = dt.NewRow();
        dt.Rows.Add(dr);
        worksheet.Cells.ImportDataTable(dt, true, "A1");
        workbook.Save(Server.MapPath(".") + @"\Report\GAD_Model_Template_" + Convert.ToString(Session["UID"]) + "_" + jobno + "_" + jobrevno + ".xls");
        ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('Data has been sucessfully expored');", true);
    }



Thanks for your kind coordination Smile !



Thanks and regards,

Parthiban K.


Use FREE Opensource EPPlus Library.

http://epplus.codeplex.com

Which version of .net framework are you targeting?


这篇关于如何在现有excel模板中的aspose单元格上打开excel工作表,并使用带有c#的asp.net在现有excel模板上编写新的excel工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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