C1Excel - FileFormat 101

While we are aiming to providing the most complex of solutions, we sometimes get stuck on the most basic of the steps. It happens to all of us, I would say that is part of being a developer, and if you are not getting stuck at the basics, its no fun at all. :) Therefore we at ComponentOne strive to make our controls, easy to use from ground up. Starting with the most basic of the functions like Loading and Saving an Excel file. What is the complexity in this, some may ask, none whatsoever, but like I said in the beginning, it’s the most basic of the steps that take the maximum time to catch. Loading and Saving files using our C1Excel library is quite simple, as expected, an argument for path, and a FileFormat enum flag value. Why this flag? Now here lies the simplicity. Once we load/save the file directly form/to a path on the machine, the mere extension of the file is enough to tell the library many things, but consider writing out to a memory stream, what of the information then? In order to facilitate this, we have provided overloads with file flags, which tell our library what to do, incase of any confusion. Below are descriptions of each of the file flags, and their intended usage,

BIFF8

The traditional .xls file format. Use this FileFormat value incase you are loading or saving an .xls file.

CSV

The traditional CSV file format. This saves the columns designated by commas, can be checked for the actual look when opened in a notepad.

OpaqueBiff8

This is a variation of the regular BIFF8 file format, this is used, when we don’t want to parse tables contained in the excel

OpenXml

This is the new .xlsx file format. This corresponds to the Office Open XML format of documents. Essentially this is a compressed file, so if you were to extract a .xslx using a decompression tool like WinZip, you would get an extracted folder structure with xml files within it. These XMLs have the actual data.

OpenXmlTemplate

This is a blurprint of an xlsx file. These are used in MSExcel as templates for creating other excels styled on it.

System.IO.Stream s1 = new System.IO.FileStream(@"..\\..\\test.xlsx",);  
 c1XLBook1.Load(s1, C1.C1Excel.FileFormat.OpenXml);

This line of code would load the specified xlsx file as an Open Office document in the C1Excel library’s C1XLBook object. Hence the use of FileFormat flags facilitates to pass on information to the ComponentOne Excel library and make things easier for you as a developer in turn. To try out more features and checkout cooler stuff, please download Studio For WinForms, here. Visit our forum here.

GrapeCity

GrapeCity Developer Tools
comments powered by Disqus