Some friends ask the code and share the Code read and write by OLE in this area. Please read it by yourself. Http://blog.csdn.net/fullsail/article/details/8449448
C ++ has many ways to read XLS files in Excel, but it may be because there are too many methods that may be confusing when you choose.
Since the table export tool was used two days ago, it is a common method. To sum up, write a short article,
1. OLE Method
This is the most commonly used method. In fact, this method starts an EXCEL process to read and write EXCEL files. The biggest benefit of this method is that everything can be done. This includes setting the EXCEL format, adding and deleting Sheet, and reading and writing cells. The function is almost the most comprehensive, and it is not particularly difficult to use.
The basic method is to use exported. H files for OLE operations. However, since there are not many OLE interface instructions, it is not easy to use them perfectly. Fortunately, there are many examples.
It is widely believed on the Internet that OLE is slow, and the OLE reading and writing methods of EXCEL are basically the same. However, the reading speed can be improved. If you load all the data in the entire Sheet Range instead of reading data from cells, the reading speed is relatively good. It's easy to think about the principle. The overall reading reduces the number of OLE interactions. Generally, the write speed of OLE is much faster than that of OLE.
My own experience is that in an EXCEL file with more than 100 columns of fields, if one cell is used to read about 3 Records in 1 s, if the whole is read, the speed can be increased by dozens of times.
The OLE-based EXCEL reading and writing method has powerful functions and the reading speed is good, but the writing speed is not high. Of course, this method cannot be transplanted, and you must install EXCEL.
2. Basic EXCEL
This is a recommended open-source project on CodeProject,
Http://www.codeproject.com/KB/office/BasicExcel.aspx
The author processes files in EXCEL format. But why is it Basic EXCEL.
He does not support many things, formulas, file formats, table merging, and so on (it is not supported when someone speaks Chinese), so he can think that he only supports the most basic EXCEL tables,
In my own attempt, if this EXCEL file has other elements (formulas, formats, etc.), reading using Basic EXCEL will fail.
OLE is relatively weak in reading and writing EXCEL files. Because it is directly operated according to the file format, the reading and writing speed is good, and you do not need to follow EXCEL. In addition, this method can be transplanted, but there are some costs, the code is obscure, and there is no comment, and even on the Windows platform, there are a lot of alarms.
3. Several EXCEL databases on Sourceforge.
There are several open-source EXCEL libraries on Sourceforge, but there are not many of them. Some of them are prepared for php excel reading and writing, including libXLS, XLSlib, and SmartEXCEL. I downloaded a few labs and did not compile them successfully in Widonws. That's all.
4. ODBC Mode
I have never tried this myself, but according to the principle, I should be able to read and write only.
Speed? ODBC speed is already known as slow.
Http://www.vckbase.com/document/viewdoc? Id = 421
It is worth mentioning that the author of Basic EXCEL originally provided an ODBC encapsulation CSpreadSheet on the CodeProject. If you are interested, you can check it out. In fact, I still admire this author.
Http://www.codeproject.com/KB/database/cspreadsheet.aspx
5. ADO Method
The method of ADO is probably OLEDB. There should be no essential difference with OLE. I looked at the example and it is similar to OLE.
6. LibXL
LibXL is a paid EXCEL library.
Http://www.libxl.com/
According to his instructions, he can read XLS files without relying on EXCEL. Including setting the format. The example operation should be simple. However, it is not difficult for me to port it to the Linux platform. Haha.
There is no way to test because of the charges.
7. Some examples of EXCEL reading without using OLE on the Internet
After a preliminary look, this should be an example of exploring EXCEL Format documents online. The actual operation method is not strong.