Jump to content
  • Advertisement
Sign in to follow this  

Read / Write XLS library? Preferably .net

This topic is 3214 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone know of a free library to read and write XLS files? That I can use from .net languages? I was using SmartXLS http://www.smartxls.com/ but I didn't realize it was only a trial and now I have a hand full of apps that are going to break on Jan 5.

Share this post

Link to post
Share on other sites
Original post by Axiverse
Hi, you can handle excel files directly with the .net framework without anything extra using the excel file as a OleDB data source. Here's some references:


There is one problem with this approach. Microsoft has no intentions on porting the Jet drivers to 64-bit, thus it will not work on any 64-bit version of windows, unless you explicitly compile your application with the CPU target set to x86.

Share this post

Link to post
Share on other sites
Hmm... Okay I got that sort of working... I'm using the code in that second link.

However on some of my excel files with multiple sheets there are some sheets that are titled like "whateverSheetName$Printarea" or "whateverSheetName$PrintTitle" but these are not visible from within excel, and when trying the program itterats over them and tries to load them I throws an exception saying the sheet is not found.

So for example I have a excel file which is a log of printed barcodes. This log has been kept for several years and each sheet is a year. So in the file I have sheets : "2005", "2006", "2007", "2008", "2009". But when the program opens the XLS and reads the sheet names....

workSheetNames = new String[dataSet.Rows.Count];
int i = 0;
foreach (DataRow row in dataSet.Rows)
//insert the sheet's name in the current element of the array
//and remove the $ sign at the end
workSheetNames = row["TABLE_NAME"].ToString().Trim(new[] { '$' });

workSheetNames is filled up like this:

And when I run the GetWorksheet function it throws an exception when trying to retrieve those sheets that say $printarea or $printtitle. on the line : cmd.Fill(excelDataSet);

What to do? Obviously I could put some check in place and ignore those strings, but I really want to understand where those are coming from and is there a way of handling them with out ignoring them outright.

Share this post

Link to post
Share on other sites
Have you tried using the override for GetOleDbSchemaTable as below?

dataSet = con.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables,
new Object[] {null, null, null, "TABLE"});

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!