It may help the community, so here is the C# code I used to evaluate the possibility of importing and exporting spreadsheetML files with the GridDesktop control:
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Aspose.Cells;
namespace AsposeEvalNet
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void openExcelFileButton_Click(object sender, EventArgs e)
{
String strImportFileName;
DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
strImportFileName = openFileDialog1.FileName;
String extn = Path.GetExtension(strImportFileName);
if (extn == “.xml” || extn == “.xls” || extn == “.xlsx”)
{
textBox1.Text = strImportFileName;
// loadSpreadSheetMLFile not available with Aspose gridDesktop but ImportExcelFile does the job (not documented)
gridDesktop1.ImportExcelFile(strImportFileName);
// A documented alternative could have been to create a workbook reading an Excel file (inc. spreadsheetML)
// in a tmp stream in memory and use ImportExcelFile to load the stream in the grid.
}
else
textBox1.Text = “MS-Excel file extension not supported (use .xml(2003) .xls .xlsx)”;
}
}
private void saveExcelFileButton_Click(object sender, EventArgs e)
{
Aspose.Cells.Workbook wbTemp;
DialogResult result = saveFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
MemoryStream ms = new MemoryStream();
gridDesktop1.ExportExcelFile(ms); // save workbook in grid as a temp stream in memory
wbTemp = new Workbook(ms); // create a new workbook reading the temp stream in memory
XlsSaveOptions savOpt = new XlsSaveOptions(SaveFormat.SpreadsheetML);
wbTemp.Save(saveFileDialog1.FileName, savOpt); // save the temp workbook as a spreasheetML file
}
}
}
}