Click here to Skip to main content
15,849,829 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi Members,

I have an ajax tab container with different tabs and inside different tabs, there are many different charts. (Please see here: http://i.stack.imgur.com/3zdox.png[^]).

Does anyone know how can I export these charts from different tabs into same excel workbook but different excel spreadsheets? For e.g. 1 tab=1 excel spreadsheet, 2 tabs = 2 different excel spreadsheets and etc. This is the output I want to achieve (Please see here: http://i.stack.imgur.com/M50R5.png[^]).

Have tried research online but can't find anything useful, all were how to export gridviews to excel.

This is my codes:
ASP.NET
//Aspx file
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>

        <asp:UpdatePanel ID="UpdatePanel1" runat="server">

            <ContentTemplate>

                <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
            </ContentTemplate>
        </asp:UpdatePanel>

C#
//c# file
protected void Page_Load(object sender, EventArgs e)
        {
           BindChart();
        }

public void BindChart()   //generate dynamic chart in different ajax tabs
        {
            //Create new TabContainer
            AjaxControlToolkit.TabContainer container = new AjaxControlToolkit.TabContainer();
            container.ID = "TabContainer";
            container.EnableViewState = false;
            container.Tabs.Clear();
            container.Height = Unit.Pixel(1000);
            container.Width = Unit.Percentage(100);

            if (Listbox1.SelectedValue == "Select All")    //If 'Select All' option is selected from Listbox1
            {
                foreach (ListItem item in Listbox1.Items)
                {
                    if (item.Text == "Select All")
                    {
                        continue;
                    }
                    AjaxControlToolkit.TabPanel panel = new AjaxControlToolkit.TabPanel();
                    panel.HeaderText += item.Text;
                    container.Tabs.Add(panel);

                    Label tabContent = new Label();
                    tabContent.ID += item.Text;
                    tabContent.Text += item.Text;

                            //Create chart
                            Chart Chart1 = new Chart();
                            Chart1.DataSource = dt;
                            Chart1.Width = 800;
                            Chart1.Height = 500;

                            Chart1.Series.Add(new Series());
                            Chart1.Series[0].ChartType = SeriesChartType.BoxPlot;

                            List<object> List_CHART = dt.AsEnumerable().ToList<object>();

                            foreach (DataRow row in dt.Rows)
                            {
                                Chart1.Series[0].Points.AddXY(row["TITLE"], new object[] { row["MIN"], row["MAX"], row["25TH_PERCENTILE"], row["75TH_PERCENTILE"], row["50TH_PERCENTILE"], row["AVG"] });
                            }

                            //create chartareas
                            ChartArea ca= new ChartArea();
                            ca.AxisX = new Axis();
                            ca.AxisY = new Axis();
                            Chart1.ChartAreas.Add(ca);

                            //databind
                            Chart1.DataBind();
                            Chart1.Visible = true;

                            panel.Controls.Add(Chart1);
                    }
                }
            PlaceHolder1.Controls.Add(container);
        }

        public AjaxControlToolkit.TabPanel GetManualTab()
        {
            AjaxControlToolkit.TabPanel panel = new AjaxControlToolkit.TabPanel();
            return panel;
        }

        protected void EXPORT_BUTTON_Click(object sender, EventArgs e)  //button to export charts to excel
        {
        }


Question: how to export many charts from different tabs into same excel workbook but different excel spreadsheets. For e.g. 1 tab=1 excel spreadsheet, 2 tabs = 2 different excel spreadsheets and so on (depending on how many tabs there are from ajax tab container).

Appreciate if someone can provide me help on this, thanks.
Posted

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