Owrytee, for months, I have been googling this
statement and all I got are also problems unsolved. Only my software
development trainor had the exact solution I am looking for. n_n
I am blogging this stuff to help people like me who has the same frustration. hihihihi :D
I am blogging this stuff to help people like me who has the same frustration. hihihihi :D
using Excel =
Microsoft.Office.Interop.Excel;
object m = Type.Missing;
Excel.Application ExcelApp = new
Excel.Application();
Excel.Workbook ImportWorkBook = ExcelApp.Workbooks.Open(“C://Names.xsls”,
m, m, m, m, m, m, m, m, m, m, m, m, m, m); -----> first parameter here is the
location of the Excel file. You can change this to the OpenFileDialog.FileName if you are using one.
Excel.WorkSheet ImportWorkSheet
= (Excel.Worksheet) ImportWorkBook.Sheets[1]; --->; “1” here
is the sheet number (Sheet1, Sheet2, ….)
Excel.Range SheetRange= ImportWorkSheet.UsedRange; --> .UsedRange indicates the rows that contains data
Int32 rowCount = SheetRange.Rows.Count;
Int32 i = 1;
Int32 i = 1;
While(i< rowCount)
{
ImportWorkSheet.get_Range("A" + i.ToString(), "A" + i.ToString()).Value2.ToString();
ImportWorkSheet.get_Range("A" + i.ToString(), "A" + i.ToString()).Value2.ToString();
---->; reading the Excel cell value (.getRange("A1", "A1"))
i++;
}
I don’t advise that you copy-paste-run this
stuff. Analyzing it will do. n_n
And yes, dont forget to close your .Close and .ReleaseCOMObject() after everything. owrytee? :)
And yes, dont forget to close your .Close and .ReleaseCOMObject() after everything. owrytee? :)
So that's it. No complicated stuff right?
All credits to my software development trainor. :)
All credits to my software development trainor. :)
If you have clarifications you can leave
comments below.
God bless yea! Happy programming!
No comments:
Post a Comment