Hi All
I have question about the Export of an UltraWinGrid in to a Infragistics.Documents.Word.Document I try to create. I found out that I have to export the UltraWinGrid with the Infragistics.Win.UltraWinGrid.WordWriter.UltraGridWordWriter. But this needs a Infragistics.Documents.Word.WordDocumentWriter. My question is now how can I reuse the output of the UltraGridWordWriter or WordDocumentWriter to past it into my Document? Or is there a better way of exporting a UltraWinGrid to a Document? I also saw in the QuickWatch that the WordDocumentWriter is using the some Objects than the Document.
THX for Help
Michael
Does no one have an Idea in this?
Hi Michael,
I'm afraid I don't understand your question. It sounds like maybe what you want to do is just select all of the rows in the grid and then copy them and paste them into Word. You could try setting the AllowMultiCellOperation property to allow copying and then this should work, I think, because the grid writes the data to the clipboard in several formats and one of them is probably acceptable to Word.
I'm afraid I still don't understand what you are trying to do. If you are writing a Word document to a file in code using the Infragistics Word engine, then you could create a document, write whatever you want to it, and use the WinGridWordExporter to write the grid into the same document.
The exporter cannot be used for pasting, though. It writes directly to a document object.
Hi Mike let me try it with some code! Please see the bold part add the end
//Create Document Infragistics.Documents.Word.Document doc = new Infragistics.Documents.Word.Document(); //Set Margin doc.FinalSection.Properties.PageMargins = new Infragistics.Documents.Word.Padding(20f, 60f, 20f, 60f); //create Table Infragistics.Documents.Word.Table tbl = doc.ContentBlocks.AddTable(); tbl.Properties.PreferredWidthAsPercentage = 100; Infragistics.Documents.Word.TableColumn column1 = tbl.Columns.Add(); column1.PreferredWidth = 10; Infragistics.Documents.Word.TableColumn column2 = tbl.Columns.Add(); column2.PreferredWidth = 200; for (int i = 0; i < 10; i++) { Infragistics.Documents.Word.TableRow row = tbl.Rows.Add(); if (i == 0) row.Cells.Add(); else { for (int x = 0; x < 2; x++) { Infragistics.Documents.Word.TableCell cell = row.Cells.Add(); cell.Properties.PreferredWidthAsPercentage = 10; cell.Properties.BorderProperties.Style = Infragistics.Documents.Word.TableBorderStyle.None; } } }
//create WordDocumentWriter Infragistics.Documents.Word.WordDocumentWriter wordDocWriter = Infragistics.Documents.Word.WordDocumentWriter.Create(@"e:\doc2.docx"); //Create UltraGridWordWriter Infragistics.Win.UltraWinGrid.WordWriter.UltraGridWordWriter ww = new Infragistics.Win.UltraWinGrid.WordWriter.UltraGridWordWriter();
///////////////// // Here is the Problem!!!! // The Export only allows me only an Export into the wordDocWriter, a Stream or in a File // And here I want to add the output of the UltraGridWordWriter in to the Document something like // Paragraph para = doc.ContentBlocks.AddParagraph(); // Infragistics.Win.UltraWinGrid.WordWriter.UltraGridWordWriter ww = new Infragistics.Win.UltraWinGrid.WordWriter.UltraGridWordWriter(); // para.AddUltraGridExport(ww.Export(ug)); ///////////////// ww.Export(ug, wordDocWriter);
//check if File exists if (File.Exists(@"e:\doc.docx")) File.Delete(@"e:\doc.docx"); //Save File doc.Save(@"e:\doc.docx"); //Open File System.Diagnostics.Process.Start(@"e:\doc.docx");
Well... maybe I am still not following you. But it sounds like you just want to add the grid into the same word document you already started. If that's the case, then why don't you just pass in the 'doc' you already created instead of creating a new one?
???
this is exactly what I'm trying todo but the Export funktion from the UltraGridWordWriter doesn't allow me this. Like I have writen the secound Parameter can only be a WordDocumentWriter, a Stream, or a string that Point to a path in the file System. so can i do this?????
Hi,
If you need any additional assistance don’t hesitate to ask.
Regards