Completed
Last Updated: 11 Dec 2015 14:55 by ADMIN
ADMIN
Ivan Petrov
Created on: 20 Jul 2012 02:58
Category: GridView
Type: Feature Request
9
ADD. RadGridView - Export to Excel- Add ability to export into xls/xlsx file format.
WORKAROUND:

The format of the file that ExportToExcelML creates is ExcelML which is an extended XML. If you do not want to receive the message, you have to change the extension of the file to ".xml". Even though the file will have an xml extension, it will still be associated with MS Excel and will be opened by Excel.There is a possibility to turn this warning message off on the client machine. You can read more about that on the following blog post - Excel 2007 Extension Warning On Opening Excel Workbook from a Web Site (http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/03/11/excel-2007-extension-warning.aspx)

Another workaround is to use Interop to open the file and excel and save it in XLSX format. However, this would require Administrator or Power User  (http://msdn.microsoft.com/en-us/library/ms173186%28v=vs.80%29.aspx). A reference from COM to the corresponding office version should be added. Here is the code for saving:

    ExportToExcelML exporter = new ExportToExcelML(this.radGridView1);

    exporter.ExportVisualSettings = true;

    string tempPath = Path.GetTempPath();

    tempPath += "tempgrid.xls";

    exporter.RunExport(tempPath);

    Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();

    if (app == null)

    {

        Console.WriteLine("EXCEL could not be started. Check that your office installation and project references are correct.");

        return;

    }

    app.Visible = false;

    app.Interactive = false;

    Microsoft.Office.Interop.Excel.Workbook wb = app.Workbooks.Open(tempPath);

    string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

    desktopPath += "\\grid.xlsx";

    wb.SaveAs(desktopPath, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault);

    wb.Close();

    app.Quit();

    Marshal.ReleaseComObject(wb);

    Marshal.ReleaseComObject(app);

    File.Delete(tempPath);
1 comment
ADMIN
Stefan
Posted on: 01 Dec 2014 07:19
We have added ability to export to xlsx (and pdf, csv, txt) via RadSpreadProcessing (http://www.telerik.com/help/winforms/spreadprocessing-overview.html). Xls is not yet supported by the library, hence the SpreadExport does not support it. A request for xls support is available here: http://feedback.telerik.com/Project/154/Feedback/Details/134691-add-support-for-import-and-export-of-xls-documents-using-radspreadprocessing.