You can load and save Microsoft Excel 2007 Open XML files within a C1FlexGrid control. Open XML is an open, standards-based format introduced by Microsoft in Office 2007. Open XML files contain a number of XML files compressed using Zip compression. Because they are compressed, Open XML files are usually much smaller than traditional document files (such as XLS files).
By default, the Load and Save methods in C1FlexGrid select the appropriate file format automatically based on the file extension. Any files with a "XLSX" or "ZIP" extensions are treated as Open XML files.
The LoadGrid and SaveGrid methods also have overloads that take the file type as a parameter. This allows you to take control over the file format and not rely on the file extension. For example, your application may use the Open XML format for its data files, but with an extension other than "XLSX". You can specify the file type as "Excel" and use the OpenXml option of the FileFlags enumeration.
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.C1FlexGrid1.SaveGrid("C:\test\myfile.xlsx", FileFormatEnum.Excel, FileFlags.OpenXml) End Sub |
To write code in C#
C# |
Copy Code
|
---|---|
private void button1_Click(object sender, EventArgs e) { this.c1FlexGrid1.SaveGrid(@"C:\test\myfile.xlsx", FileFormatEnum.Excel, FileFlags.OpenXml); } |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.C1FlexGrid1.Clear(ClearFlags.All) End Sub |
To write code in C#
C# |
Copy Code
|
---|---|
private void button2_Click(object sender, EventArgs e) { this.c1FlexGrid1.Clear(ClearFlags.All); } |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Me.C1FlexGrid1.LoadGrid("C:\test\myfile.xlsx", FileFormatEnum.Excel, FileFlags.OpenXml) End Sub |
To write code in C#
C# |
Copy Code
|
---|---|
private void button3_Click(object sender, EventArgs e) { this.c1FlexGrid1.LoadGrid(@"C:\test\myfile.xlsx", FileFormatEnum.Excel, FileFlags.OpenXml); } |