After using SaveFileDialog and buiding the filestream, I do Workbook.Save(filestream). After this the contents of the grid is exported and saved in the excel sheet. Our users however want the excel sheet to remain open? Even better solution would be to build the filestream and popup a prompt for the user to either Open or Save or Cancel the operation. How do I do it?
OK, please post back if you run into question that we can assist with.
Thanks Francis, I will try and implement the same.
Hello,
I spoke about this with one of our engineers. You only option is to send the XLS file back to the server, then in Silverlight or your HTML page, open a popup window pointing at the saved file on the server. This would prompt the end user to open the XLS.
I hope this helps...
This is not something you could do "directly" through the XamGrid, but would take some programming with the Silverlight API. I do not have any samples that do this, but I will discuss this further with our engineers. From what I was told so far, you'd likely need to send the Excel file to the server and back down to the browser.
Although the follwing information does not apply to your situation, I also want to post a solution for this functionality that would apply for out-of-browser applications:
Code to open an excel file from a Silverlight out of browser app using SL4 COM automation:
// Create the Excel object dynamic excel = AutomationFactory.CreateObject("Excel.Application"); string path = System.IO.Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"Customer Samples\JPMC\JPMC.Pi.Web.DataCollectionForm\TestWorkbooks\testtrialbalance.xlsx"); // Open the excel document. Must be located in "My Documents" dynamic excelWorkBook = excel.Workbooks.Open(path); excel.Visible = true;
The app must be running with elevated privileges, and requires a reference to Microsoft.CSharp so we can use the ‘dynamic’ keyword.
For more informatio, you can refer to this tutuorial:
http://www.silverlight.net/learn/tutorials/silverlight-4/advanced-silverlight-out-of-browser-introduction/
Its within a browser. I am exporting it from XamGrid.
SaveFileDialog dialog = new SaveFileDialog {"Excel 2003 files (.xls)|*.xls" , DefaultExt = "xls"
Filter =
};
bool? showDialog = dialog.ShowDialog();
if (showDialog == true )
{
using (Stream exportStream = dialog.OpenFile())
try {WorkbookFormat workbookFormat = WorkbookFormat.Excel97To2003;
Workbook dataWorkbook = new Workbook (workbookFormat);
. . .
// save the workbook
dataWorkbook.Save(exportStream);
}