Janus Gridex Exporter to excel

1.2k views Asked by At

I'm using Janus gridex and Janus gridex exporter. I have one problem when I wanna export it to excel. actually below is my code

Dim filep = ""
    Dim saveDialog As New SaveFileDialog
    saveDialog.DefaultExt = "xls"
    saveDialog.Filter = "Excel File (*.xlsx)|*.*"
    If saveDialog.ShowDialog() = DialogResult.OK Then
        Using st As New IO.FileStream(saveDialog.FileName, FileMode.Create, FileAccess.Write, FileShare.None)
            GridEXExporter1.Export(st)

            filep = saveDialog.FileName
        End Using
    End If

during export it working fine but it allow only extension .xls for .xlsx it not allow and it always pop up asking message before user open that file. anyone has some solution please kindly help. Thanks.

3

There are 3 answers

0
Mostafa Bagheri On

this is a sample export to excel in C#

            Stream sw = null;
            gridEXExporter1.GridEX = this;
            gridEXExporter1.SheetName = "sheetName";
            if (gridEXExporter1.GridEX.GetCheckedRows().Length == 0)
            {
                gridEXExporter1.ExportMode = ExportMode.AllRows;
            }
            else
            {
                gridEXExporter1.ExportMode = ExportMode.CheckedRows;
            }


            var sd = new SaveFileDialog { Filter = "Excel File (*.xls)|*.xls", FileName = $"Report{Guid.NewGuid()}.xls" };
            if (sd.ShowDialog() != DialogResult.OK) return;
            sw = new FileStream(sd.FileName, FileMode.Create);
            gridEXExporter1.Export(sw);
            Process.Start(sd.FileName);
2
eaydemir On

rename extension to .xml, and open that file from excel.

0
Random Coder On

This is more of a cheap hack than a fix, but you could use:

System.IO.File.Move("oldfilename", "newfilename");

to rename the extension to .xlsx