We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Facing the error in the Template file(Data is inserted instead of pasting in predefined -Here i have attached the both the file and also Code the regarding the file .Please find the attachment as same.Please revert back immediately

Thank for your support!We are facing the error in the Template file(Data is inserted instead of pasting in predefined Template in the second sheet) ,Here i have attached the both the file and also Code the regarding the file .Please find the attachment as same.Please revert back immediately,

#region GAD_MRL

if (dsProduct.Tables[0].Rows[0][0].ToString() == "GAD_MRL")

{

//workbook.Open(@"C:\\Windows\SysWOW64\config\systemprofile\desktop\GAD_MRL.xls");

workbook = new Aspose.Cells.Workbook(@"C:\\Windows\SysWOW64\config\systemprofile\desktop\GAD_MRL.xls");

//Worksheet worksheet = workbook.Worksheets.Add("GAD_Model_Template" + "_" + jobno + "_" + jobrevno + "");

Aspose.Cells.Worksheet worksheet = workbook.Worksheets["GAD_Model"];

DataRow dr = dt.NewRow();

dt.Rows.Add(dr);

worksheet.Cells.ImportDataTable(dt, true, "A1");


//workbook.Save(Server.MapPath(".") + @"\GADReport\GAD_Model_Template_" + Convert.ToString(Session["UID"]) + "_" + jobno + "_" + jobrevno + ".xls");

workbook.Save(@"C:\\Windows\SysWOW64\config\systemprofile\desktop\GAD_MRL_" + Convert.ToString(Session["UID"]) + "_" + jobno + "_" + jobrevno + ".xls");

string GAD_Template = string.Empty;

GAD_Template = "GAD_MRL_" + Convert.ToString(Session["UID"]) + "_" + jobno + "_" + jobrevno + ".xls";

Aspose.Cells.Workbook WB = new Aspose.Cells.Workbook();

WB.Worksheets.Clear();

//WB.Open(Server.MapPath(".") + @"\GADReport\" + GAD_Template + "");

//WB.Open(@"C:\\Windows\SysWOW64\config\systemprofile\desktop\" + GAD_Template + "");



WB = new Aspose.Cells.Workbook(@"C:\\Windows\SysWOW64\config\systemprofile\desktop\" + GAD_Template + "");

Aspose.Cells.Worksheet worksheet1 = WB.Worksheets["GridData"];

DataRow dr1 = dt1.NewRow();

dt1.Rows.Add(dr1);

worksheet1.Cells.ImportDataTable(dt1, true, "A1");


//WB.Save(Server.MapPath(".") + @"\GADReport\GAD_Model_Template_" + Convert.ToString(Session["UID"]) + "_" + jobno + "_" + jobrevno + ".xls");

WB.Save(@"C:\\Windows\SysWOW64\config\systemprofile\desktop\GAD_MRL_" + Convert.ToString(Session["UID"]) + "_" + jobno + "_" + jobrevno + ".xls");


Session["GADfilepath"] = "GAD_MRL_" + Convert.ToString(Session["UID"]) + "_" + jobno + "_" + jobrevno + ".xls";

}

#endregion

Hi,


Thanks for the template files and sample code.

Although I am not entirely certain about your issue, but if you meant when you import datatable to the second worksheet via Aspose.Cells APIs, it first inserts blank rows and then paste data into those blank rows and consequently your formatted range (cells set with borders and other formatting) are moved/shifted below, well, you may try to change the line of code from your code segment:
i.e.,
Aspose.Cells.Worksheet worksheet = workbook.Worksheets[“GAD_Model”];

DataRow dr = dt.NewRow();

dt.Rows.Add(dr);

worksheet.Cells.ImportDataTable(dt, true, “A1”);


to:
Aspose.Cells.Worksheet worksheet = workbook.Worksheets[“GAD_Model”];

DataRow dr = dt.NewRow();

dt.Rows.Add(dr);

worksheet.Cells.ImportDataTable(dt, true, 0,0, false);

it would work fine. Please note if you want the data should be inserted into existing range of cells (instead of first inserting blank rows and then paste data into them), you should pick relevant ImportDataTable() overloaded method where you will specify insertRows Boolean parameter (last parameter) to “false”.

Let us know if you still have any issue.

Thank you.


Thanks for the support! Its works fine in the local Machine ,but it does not work in the server.Please check and revert back.

Thanks & Regards

Hi,


Please make sure that you have updated your code segment (as suggested) in your project on the server, it should equally work fine there. Aspose.Cells does not depend on machine (development/ desktop PC or enterprise higher configured server) or OS , it would work fine where .NET framework is installed and it only needs .NET framework version => 2.0 to work with.

If you still have the issue, kindly create a separate simple sample console application (runnable) to reproduce the issue on our end, we will check it soon.

Thank you.