How can I Read Excel-documents?
-
Hi! I have been looking all over internet after an Excel-component to use for reading excel-documents and calculate formulas. Anyone know wher i can find it?` //Maw
It's called Excel. There's no way I know of, apart from controlling Excel through the Microsoft Office SDK, whatever they call that thing.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Hi! I have been looking all over internet after an Excel-component to use for reading excel-documents and calculate formulas. Anyone know wher i can find it?` //Maw
Here is one way, although there may be other/better ways: Add a reference to the MS Excel object library. In your code, you can use the Excel objects directly: Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xlBooks As Excel.Workbooks Dim xlSheets As Excel.Sheets Dim xlSheet As Excel.Worksheet Once you create an instance of the Excel app, xlApp = New Excel.Application You can address any object in the spreadsheet xlBooks = xlApp.Workbooks xlBook = xlBooks.Open(strPath & "Sheetname.xls", True) xlSheets = xlBook.Worksheets xlSheet = xlSheets(1) Values in cells can be accessed and modified by range intListRow += 1 strRange = "A" & CStr(intListRow) strSheetValue = xlSheet.Range(strRange).Value Remember to close the app or there will be an Excel process still open on the machine. xlBook.Close(True) xlApp.Application.Quit() xlApp = Nothing