Koogra is an open-source MIT Licensed library for reading Excel files: it's latest release supports Excel 2007 format.
I use it for an app which imports Excel spreadsheets: using the Office interop libraries is awkward and brittle, and it has to work with an existing install of Office which you can't control versioning or upgrading. So, Koogra. I don't need to write to the spreadsheets, just read them.
There are at least three distinct syntaxes in Koogra:
•Excel 2007 syntax
•Excel 2003 syntax (more accurately, 97-2003)
•The interface syntax which links the two together
For example, finding a worksheet by name:
using Net.SourceForge.Koogra;
using Excel2003 = Net.SourceForge.Koogra.Excel;
using Excel2007 = Net.SourceForge.Koogra.Excel2007;
// The Excel 2003 syntax for opening a worksheet
Excel2003.Workbook workbook = new Excel2003.Workbook(fileName);
Excel2003.Worksheet worksheet = workbook.Sheets.GetByName(sheetName);
// The Excel 2007 syntax
Excel2007.Workbook workbook = new Excel2007.Workbook(fileName);
Excel2007.Worksheet worksheet = workbook.GetWorksheetByName(sheetName);
// The interface syntax
IWorkbook workbook;
if (Path.GetExtension(fileName).ToLower() == ".xlsx")
{
workbook = new Excel2007.Workbook(fileName);
}
else
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余4页未读,立即下载