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
Ajit N
NA
352
71.2k
How to set Border to excel when we export datagrid to excel?
Dec 23 2016 5:37 AM
Hello, i simply export the datagridview into excel. now, I want to set border to data in excel.
so how can i do this, help me for the solution.
this is the code of export datagridview to excel.
private
void
btnexport_Click(
object
sender, EventArgs e)
{
if
(dataGridView1.Rows.Count > 0)
{
Microsoft.Office.Interop.Excel._Application XcelApp =
new
Microsoft.Office.Interop.Excel.Application();
XcelApp.Application.Workbooks.Add(Type.Missing);
for
(
int
i = 1; i < dataGridView1.Columns.Count + 1; i++)
{
XcelApp.Cells[1, i] = dataGridView1.Columns[i - 1].HeaderText;
}
for
(
int
i = 0; i < dataGridView1.Rows.Count; i++)
{
for
(
int
j = 0; j < dataGridView1.Columns.Count; j++)
{
XcelApp.Cells[i + 2, j + 1] = dataGridView1.Rows[i].Cells[j].Value;
}
}
XcelApp.Columns.AutoFit();
XcelApp.Visible =
true
;
}
}
i want the excel in this format.
Reply
Answers (
2
)
The remote server returned an error: (403) Forbidden
com add ins go inactive mode in Excel