SpreadJS Documentation > Developer's Guide > Managing Data > Using the Excel Import and Export Component > Using the Excel Import and Export Component in a Windows Forms Application |
This example shows how to use the Excel Import and Export component in a Windows Forms application.
Use the following steps to create the sample:
C# |
Copy Code
|
---|---|
using GrapeCity.Spread.Sheets.ExcelIO; using GrapeCity.Windows.SpreadSheet.Data; using System; using System.IO; using System.Windows.Forms; private void importBtn_Click(object sender, EventArgs e) { DialogResult result = this.openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { using (Stream stream = File.Open(this.openFileDialog1.FileName, FileMode.Open)) { Importer importer = new Importer(); this.resultRtb.Text = importer.ImportExcel(stream); } } } private void exportBtn_Click(object sender, EventArgs e) { DialogResult result = this.saveFileDialog1.ShowDialog(); if (result == DialogResult.OK) { using (FileStream fs = File.Create(this.saveFileDialog1.FileName)) { Exporter exporter = new Exporter(this.resultRtb.Text); exporter.SaveExcel(fs, ExcelFileFormat.XLSX, ExcelSaveFlags.NoFlagsSet); } } } |