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
Dinesh Santhalingam
NA
737
368.6k
Datatable to Excel (Excel formatting)
Mar 28 2017 5:44 AM
I have a data table .I want to Export it to a Excel file.I did it using the following code.
StreamWriter
wr
=
new
StreamWriter(@"E:\\Book1.xls");
// Write Columns to excel file
for (int
i
=
0
; i
<
dt.Columns.Count
; i++)
{
wr.Write(dt.Columns[i].ToString().ToUpper() + "\t");
}
wr.WriteLine();
//write rows to excel file
for (int
i
=
0
; i
<
(dt.Rows.Count); i++)
{
for (int
j
=
0
; j
<
dt.Columns.Count
; j++)
{
if (dt.Rows[i][j] != null)
{
wr.Write(Convert.ToString(dt.Rows[i][j]) + "\t");
}
else
{
wr.Write("\t");
}
}
wr.WriteLine();
}
wr.Close();
label1.Text
=
"Data Exported Successfully"
;
}
catch (Exception ex)
{
throw ex;
}
But I want Some Cell Formatting in Xls .Want to change the color of the entire cell like that something.Please help me to solve my problem.
Reply
Answers (
3
)
how to avoid nested for looping for improved performance?
Disable zoom and drag from d3 line graph in WPF C#