TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ishak Khan
NA
25
5.8k
Export line chart into excel using asp.net
May 2 2017 2:35 AM
///// Here i export gridview into excel but i need to do line chart also //////
private void ExportToExcel()
{
try
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=OverallReport.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
using (StringWriter sw = new StringWriter())
{
HtmlTextWriter hw = new HtmlTextWriter(sw);
//To Export all pages
dgvTrendChart.AllowPaging = false;
this.SearchOverallList();
dgvTrendChart.HeaderRow.BackColor = Color.White;
foreach (TableCell cell in dgvTrendChart.HeaderRow.Cells)
{
cell.BackColor = dgvTrendChart.HeaderStyle.BackColor;
}
for (int rowIndex = dgvTrendChart.Rows.Count - 2; rowIndex >= 0; rowIndex--)
{
GridViewRow row = dgvTrendChart.Rows[rowIndex];
GridViewRow previousRow = dgvTrendChart.Rows[rowIndex + 1];
for (int i = 0; i < row.Cells.Count; i++)
{
if (i != 3)
{
if (row.Cells[i].Text == previousRow.Cells[i].Text)
{
row.Cells[i].RowSpan = previousRow.Cells[i].RowSpan < 2 ? 2 :
previousRow.Cells[i].RowSpan + 1;
previousRow.Cells[i].Visible = false;
row.Cells[i].HorizontalAlign = HorizontalAlign.Center;
row.Cells[i].VerticalAlign = VerticalAlign.Top;
}
}
}
}
dgvTrendChart.RenderControl(hw);
//style to format numbers to string
string style = @"<style> .textmode { } </style>";
Response.Write(style);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
}
}
catch
{
//throw new Exception("");
}
}
Reply
Answers (
3
)
validation- before and after decimal take only two digits
hid omnikey 3121 usb card reader