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
darma teja
NA
496
336.4k
save data from every loop in excel
Apr 3 2013 2:27 PM
Hi All,
I wanted to export data to excel.
here is the code that i wrote:
Microsoft.Office.Interop.Excel.Application xla = new Microsoft.Office.Interop.Excel.Application();
Workbook vb = xla.Workbooks.Add(XlSheetType.xlWorksheet);
var Worksheet = (Worksheet)xla.Worksheets.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing);
foreach (logic)
{
//logic to get data
// I put data to excel cells
example: Worksheet.Cells[i + 1, 1] = bla bla;
}
Worksheet ws = (Worksheet)xla.ActiveSheet;
ws.SaveAs(@"c:\Documents and Settings\Desktop\output1.xls");
Now my problem is: I dont want to save xls file in last step.
I want to save data in excel file in every loop. It means that If any exception comes at least I have data of the passed loops.
Many thanks,
Darma
Reply
Answers (
2
)
Data type mismatch in criteria expression.
read text from txt file