Windows Develop Bookmark and Share   
 index > Windows Forms General > Problem while handling excel file
 

Problem while handling excel file

Hi to all,

I m developing a window application which is comparing 2 excel files and insert result in 3rd excel file.I want to delete previous records from the 3rd file and then insert new record, i m doing this by making all rows blank but becoz operation is commiting at the endof event,it is blanking the previous rows but append records after the blank rows, how can i save excel file in between the event.

At the same time i also can't able to find the "Microsoft.Office.Interop.Excel" Namespace even i added Microsoft.excel 11.0 reference also.

Plz help me,its urgent.

Fozia Izhar  Friday, October 05, 2007 7:27 AM

Add a reference to the "Microsoft Excel 11.0 Object Library" should make the "Microsoft.Office.Interop.Excel" Namespaces available. And should clear the WorkSheet, ad set content in the specify cell, something like this

Code Block

void button2_Click(object sender, EventArgs e)

object oMissing = Missing.Value;

Application ExcelObj =

new Microsoft.Office.Interop.Excel.Application();

Workbook WBook;

Worksheet WSheet;

@"c:\test\a.xlsx",

Worksheet)WBook.Sheets.get_Item(1);

"aaaa";

true;

Marshal.ReleaseComObject(WSheet);

Marshal.ReleaseComObject(WBook);

Marshal.ReleaseComObject(ExcelObj);

null;

null;

null;

GC.Collect();

Add a reference to the "Microsoft Excel 11.0 Object Library" should make the "Microsoft.Office.Interop.Excel" Namespaces available. And should clear the WorkSheet, ad set content in the specify cell, something like this

Code Block

void button2_Click(object sender, EventArgs e)

object oMissing = Missing.Value;

Application ExcelObj =

new Microsoft.Office.Interop.Excel.Application();

Workbook WBook;

Worksheet WSheet;

@"c:\test\a.xlsx",

Worksheet)WBook.Sheets.get_Item(1);

"aaaa";

true;

Marshal.ReleaseComObject(WSheet);

Marshal.ReleaseComObject(WBook);

Marshal.ReleaseComObject(ExcelObj);

null;

null;

null;

GC.Collect();

You can use google to search for other answers

Custom Search

More Threads

• DragDrop file into RichTextBox *without* icon?
• Docking & anchoring two windows
• Controls at the runtime????
• Problem with selecting items in a ListBox
• Changing the size of controls-- chekboxes etc
• Bindingsource & Tableadapter not updating database.
• Databinding "Fun" with Interfaces...
• Creating Print document
• Application window frame
• Drag n'Drop to Combobox