Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a export function using EPPLUS to export my gridviews data into separated worksheets(this part works) however I have a problem with my exporting my tabcontainer contents which is added into a placeholder.

My ajaxtoolkit tabcontainer consist of multiple tab panels and each tabpanel consists of multiple charts. I would like to know how can I export the whole content in each tabpanel as a image to each worksheet. For example if I have 5 tabpanel, it should be placed in 5 different worksheet. and each worksheet contains a image of the whole content in the tabpanel.

Please advice thanks. How can add in my export codes to be able to export every AjaxControlTookKit TabPanel contents in each tab as image into excel with my current codes?

The below is my current working codes for exporting gridviews to excel.

C#
ExcelPackage package = new ExcelPackage();

            ExcelWorksheet gridview1= package.Workbook.Worksheets.Add("gridview 1");
            ExcelWorksheet gridview2= package.Workbook.Worksheets.Add("gridview 2");

            DataTable gridview1= new DataTable();
            for (int i = 0; i < gridview_1.Columns.Count; i++)
            {
                gridview1.Columns.Add("column" + i.ToString());
            }

            foreach (GridViewRow row in gridview_1.Rows)
            {
                DataRow dr = gridview1.NewRow();
                for (int j = 0; j < gridview_1.Columns.Count; j++)
                {
                    row.Cells[j].Text = row.Cells[j].Text.Replace(" ", " ");
                    dr["column" + j.ToString()] = row.Cells[j].Text;

                }

                gridview1.Rows.Add(dr);
            }

gridview1.Cells["A1"].LoadFromDataTable(gridview1, true);

  DataTable gridview2= new DataTable();
            for (int i = 0; i < gridview_2.Columns.Count; i++)
            {
                gridview2.Columns.Add("column" + i.ToString());
            }

            foreach (GridViewRow row in gridview_1.Rows)
            {
                DataRow dr = gridview2.NewRow();
                for (int j = 0; j < gridview_2.Columns.Count; j++)
                {
                    row.Cells[j].Text = row.Cells[j].Text.Replace(" ", " ");
                    dr["column" + j.ToString()] = row.Cells[j].Text;

                }

                gridview2.Rows.Add(dr);
            }

gridview2.Cells["A1"].LoadFromDataTable(gridview2, true);

Response.Clear();
package.SaveAs(Response.OutputStream);
Response.AddHeader("content-disposition", "attachment; filename=" + filename + ";");
Response.Charset = "";
Response.ContentType = "application/vnd.xlsx";
Response.End();
Posted
Updated 21-Oct-15 22:28pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900