5,545,925 members and growing! (18,511 online)
Email Password   helpLost your password?
Enterprise Systems » Office Development » Microsoft Excel     Intermediate License: The Code Project Open License (CPOL)

Excel Reader

By Liu Junfeng

Read Excel files in pure C# without interop.
C# 2.0, C#, Windows, .NET, .NET 2.0, Visual Studio, Dev

Posted: 1 Nov 2006
Updated: 27 May 2007
Views: 93,941
Bookmarked: 94 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
35 votes for this Article.
Popularity: 7.00 Rating: 4.53 out of 5
1 vote, 2.9%
1
2 votes, 5.9%
2
0 votes, 0.0%
3
1 vote, 2.9%
4
30 votes, 88.2%
5

Sample Image - ExcelReader.png

Introduction

This library is built based on the following documents, thanks to their authors:

Record structures in BIFF8/BIFF8X format are considered.

What it can do?

  • It can read read worksheets in a workbook and read cells in a worksheet.
  • It can read cell content (text, number, datetime, or error) and cell format (font, alignment, linestyle, background, etc.).
  • It can read pictures in the file, get information of image size, position, data, and format.

Using the code

  1. Open file:
    Stream fileStream = File.OpenRead(file);
    Workbook book = new Workbook();
    book.Open(fileStream);
    Worksheet sheet = book.Worksheets[0];
  2. Read cell:
    int row = 1;
    int col = 0;
    string ID = sheet.Cells[row, col].StringValue;
    
    Picture pic = sheet.ExtractPicture(row, col);

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Liu Junfeng



Occupation: Software Developer
Location: China China

Other popular Office Development articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 61 (Total in Forum: 61) (Refresh)FirstPrevNext
Subject  Author Date 
QuestionUnreadable textmemberAskewDW23:16 21 Aug '08  
GeneralMajor truncating errormemberSinbios19:24 11 Aug '08  
GeneralRe: Major truncating errormemberSinbios3:13 14 Aug '08  
GeneralNot able to find the provision to read the named cell value and its commentmemberMember 44485876:04 6 Aug '08  
QuestionHeader problemsmemberhumble.apprentice6:33 18 Jul '08  
AnswerRe: Header problemsmemberkianno2:35 23 Jul '08  
AnswerRe: Header problemsmemberLiu Junfeng17:13 5 Aug '08  
GeneralRe: Header problemsmemberhumble.apprentice22:16 5 Aug '08  
GeneralLibrary?!memberilhyfe3:25 7 Jul '08  
GeneralRe: Library?!memberphilvx6:12 8 Jul '08  
GeneralEdit the file?memberwarnov19:53 4 May '08  
Generalcolor in cellsmembermandrij10:46 19 Feb '08  
GeneralCell formatsmemberMember 37914596:32 15 Feb '08  
GeneralFormulasmemberragundo22:06 15 Dec '07  
QuestionInternationalitation problemmemberragundo9:19 11 Dec '07  
GeneralRe: Internationalitation problemmemberragundo7:37 12 Dec '07  
GeneralRe: Internationalitation problemmemberNandkishor Sonar14:15 19 Jul '08  
GeneralRe: Internationalitation problemmemberragundo22:49 19 Jul '08  
GeneralPls HelpmemberGovind Bhanushali23:28 14 Nov '07  
AnswerRe: Pls HelpmemberLiu Junfeng3:42 16 Nov '07  
GeneralWrong DateTime with certain cell values?memberotyrland12:34 31 Oct '07  
GeneralProblem with PeekChar()memberilogpasig16:54 25 Sep '07  
GeneralCoding errors, style comments.memberThePhantasm8:51 8 Sep '07  
GeneralRe: Coding errors, style comments.memberLiu Junfeng22:57 23 Sep '07  
GeneralRe: Coding errors, style comments.memberilogpasig18:52 24 Sep '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 27 May 2007
Editor: Sean Ewington
Copyright 2006 by Liu Junfeng
Everything else Copyright © CodeProject, 1999-2008
Web11 | Advertise on the Code Project