Is there a way I can get some ExcelReader class? I don't want to use ADO.NET. Thanks in advance!
Printable View
Is there a way I can get some ExcelReader class? I don't want to use ADO.NET. Thanks in advance!
Unless you want to read an XLS file in binary form and decipher it you'll either have to use Office Automation or ADO.NET.
There is an Excel Viewer Utility but just for viewing the xls file without having to have Excel installed.
If thats not acceptable then automate Excel. What do you want to do with it?
I really love to see something like:
:DCode:public void Test3()
{
ExcelReader e = new ExcelReader("Some.xls");
e.WorkSheet = "WorksheetName";
ExcelRow r = e.First();
while (r != null)
{
Console.WriteLine(r["A"].ToString());
Console.WriteLine(r["B"].ToString());
Console.WriteLine(r["C"].ToString());
r.Next();
}
}
Fine! :D
Got tired of formatting the code to look nice so I just attached it for you.
It creates an Excel.Application object and on the form it has a browse button to open a workbook. Then the left button will write a value to cell A1 and save the workbook. Then when you close the form, Excel closes properly.
Whew!!! :D
Ps, sorry about naming the buttons with relevant names and stuff. ;)
Edit: 28,000 POSTS! Meow!
Hehehe. Ok thanks but I know a little about this stuff. Anyway, I just create my ExcelReader class encapsulating the ones you posted plus Iterator. Thanks again!
Np, I just noticed I forgot to change a line of code to open the workbook in the textbox instead of my test hard coded file. :blush:
VB Code:
Excel.Workbook oWB = (Excel.Workbook)moApp.Workbooks.Open([b]@textBox1.Text[/b],objMissing,objMissing,...
hi RobDog888. I have to create a program to do some excel manipulation and your program helped me a lot that you attached.
However there's 2 lines in your code:
using Excel = Microsoft.Office.Interop.Excel;
///Add a reference to MS Excel xx.0 Object Library
Where could I get this reference / Dll? I hope this is not a silly question, if it was forgive me, its the first tiem I'm doing this.
This is since i'm getting the error that :
The type or namespace name 'Interop' does not exist in the class or namespace 'Microsoft.Office' (are you missing an assembly reference?)
Jennifer.
You add a reference to the appropriate Office application's object library from the COM tab.Quote:
Originally Posted by JenniferBabe
Thanks!