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
TheOne
NA
3
20.8k
Column Width Excel file
Mar 6 2012 4:55 AM
Hi,
I created an Excel file from a datatable but i have a problem to resize column, this is the first problem. The second is how can i write in a specific cell(for example the cell(1,2) I need this for the header for example).Can you help me?.This is my code
DataTable dt = (DataTable) ViewState["CurrentTable"];
Workbook book = new Workbook();
WorksheetStyle style = book.Styles.Add("Entete");
style.Font.Bold = true;
style.Font.Color = "White";
style.Alignment.Horizontal = StyleHorizontalAlignment.Center;
style.Interior.Color = "Blue";
style.Interior.Pattern = StyleInteriorPattern.Solid;
//create the first sheet
Worksheet sheet = book.Worksheets.Add("Detail Seance");
//The second sheet
Worksheet sheetConf = book.Worksheets.Add("Total");
//The header
WorksheetRow row = sheet.Table.Rows.Add();
row.Cells.Add(new WorksheetCell("Historique Exo"){ MergeAcross = 5 });
row = sheet.Table.Rows.Add();
Excel.Range range;
foreach (DataColumn dc in dt.Columns)
{
row.Cells.Add(new WorksheetCell(dc.ColumnName, DataType.String, "Entete"));
}
int j;
foreach (DataRow dr in dt.Rows)
{
row = sheet.Table.Rows.Add();
for (j = 0; j < dt.Columns.Count; j++)
{
row.Cells.Add(new WorksheetCell(dr[j].ToString()));
//I want for example to specify the width of the cell added
}
}
//save Excel file
book.Save(Response.OutputStream);
I hope that you can help
tahnks
Reply
Answers (
2
)
How to Export Grind View data to excel?
internal and static