Hi,is it possible to export data in Excel or Pdf from my UltraGrid for WinForms?
Thanks very much.
Luigi
Hi Luigi,
Yes.
To export to Excel, you would use the UltraGridExcelExporter component.
For PDF or XPS, you would use the UltraGridDocumentExporter component.
Thank you Mike, it works fine.
A little addings:
In my PDF export I have this code:
private void pDFToolStripMenuItem_Click(object sender, EventArgs e) { ultraGridDocumentExporter1.Export(ultraGridBrani, @"C:\ExportBrani.pdf", GridExportFileFormat.PDF); }
but the Grid it save the file without give me any warning that the pdf file is in C drive. How can I force to tell the user that the Pdf is saved in this path and with this name?
Sorry, I mean something like un upload file, where the user can choose the name and the path where save the file.
I'm still not sure what you are asking. You choose the file name to save to. If you want the user to choose a filename, then you should probably use the SaveFileDialog component in DotNet. That has nothing to do with the WinGrid or the ExcelExporter, though.
Hi Mike,thanks for response.I'll trying to using the SaveFileDialog .NET component in my click event export button (when I want to export in Pdf format).saveFileDialog1.OpenFile();if (DialogResult.OK == saveFileDialog1.ShowDialog(this)){ ultraGridDocumentExporter1.Export(ultraGridBran, saveFileDialog1.FileName, GridExportFileFormat.PDF); }but does not runs.Do you have any idea of that?Luigi
What's the problem? Does it not compile? Are you getting an error? Are you saying this code gets called by the dialog does not display?
The SaveFileDialog is built-in to the DotNet Framework and it has nothing to do with the Infragistics controls. I can't imagine why it would not be working, but if that's the case, you might want to try posting on a Microsoft or a more general DotNet forum for assistance.
Hi Mike,now it works.I've made in this way.// PDF Export private void pDFToolStripMenuItem_Click(object sender, EventArgs e) { var nomeFilePdf = String.Empty; try { saveFileDialog1.Filter = "(*.pdf)|*.pdf|Tutti i file (*.*)|*.*"; saveFileDialog1.AddExtension = true; saveFileDialog1.DefaultExt = ".pdf"; saveFileDialog1.ShowDialog(); nomeFilePdf = saveFileDialog1.FileName + ".pdf"; if (saveFileDialog1.FileName != "") ultraGridDocumentExporter1.Export(ultraGridBrani, nomeFilePdf, GridExportFileFormat.PDF); else { MessageBox.Show("Fornire un nome per il file PDF da salvare", "PDF Export", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } catch (Exception ex) { MessageBox.Show("Errore nella creazione del file Pdf: \n" + ex.Message, "PDF Export", MessageBoxButtons.OK, MessageBoxIcon.Error); } var messaggio = "File " + nomeFilePdf.Trim() + " salvato correttamente"; MessageBox.Show(messaggio, "Save PDF file", MessageBoxButtons.OK, MessageBoxIcon.Information); }