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
R.D Ip
NA
76
8.3k
how to add new row sum of column in excelsheet
May 19 2021 10:16 AM
I am working with excelsheet
I am trying to add sum of column in new row but not able to add sum of column
Current Output:
Expected Output(I want to below output):
see code:
private
void
AddExcelSheet(DataTable sDT, ExcelWorksheet excelWorksheet)
{
DataTable dtCustomDetail =
new
DataTable();
dtCustomDetail.Columns.Add(
"Id"
,
typeof
(
string
));
dtCustomDetail.Columns.Add(
"Name"
,
typeof
(
string
));
dtCustomDetail.Columns.Add(
"Cust Name"
,
typeof
(
string
));
dtCustomDetail.Columns.Add(
"Cust Qty"
,
typeof
(
int
));
if
(sDT !=
null
&& sDT.Rows.Count > 0)
{
foreach
(DataRow Dr
in
sDT.Rows)
{
DataRow DRowDetail = dtCustomDetail.NewRow();
DRowDetailCO[
"Id"
] = Dr[
"Cust_Id"
].ToString();
DRowDetailCO[
"Name"
] = Dr[
"Name"
].ToString();
DRowDetailCO[
"Cust Name"
] = Dr[
"CUST_NAME"
].ToString();
DRowDetailCO[
"Cust Qty"
] = Dr[
"Cust_QTY"
].ToString();
dtCustomDetail.Rows.Add(DRowDetails);
}
}
excelWorksheet.Cells[2, 1].LoadFromDataTable(dtCustomDetail,
true
);
//here load my table
excelWorksheet.Cells[].Formula =
"=SUM(D3:D"
+ (6) +
")"
;
//here I am trying to add some of column in new line but I am stuck
why I am using foreach loop because I have not idea how many data in table so I use foreach loop
now I want to add a new column for some but I have no idea
please help
Reply
Answers (
1
)
error CS0234: The type or namespace name 'Hosting' does not exist in t
consume web api without database