Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
35
Ultragrid Word export wrong format first row
posted

Hi all,

I have a problem exporting an UltraGrid to a Word document using the UltraGridWordWriter. Basically the export is working and all the data and formatting from the grid is saved to the Word document with one exception, the format of the first cell/row is different. Example (first cell has font size 11 instead of 9 as all oth the other cells):

Here is the code where the UltraGridWorkWriter is created and additional logic is defined:

        private static void ExportDoc(UltraGrid grid, Stream target)
        {
            using (var exporter = new UltraGridWordWriter())
            {
                exporter.CellExporting += (sender, e) =>
                {
                    // fix null values (throws exception)
                    if (e.CellValue == null)
                    {
                        e.ExportValue = string.Empty;
                    }

                    // fix editor control (wrong format)
                    if (e.GridColumn.Editor != null)
                    {
                        e.GridColumn.Editor = null;
                        e.GridColumn.EditorComponent = null;
                    }
                };
                exporter.Export(grid, target);
            }
        }

The most important part is the reset of the Editor. I noticed that the UltraGridWordWriter sets the font format based on the used editor. In our case we use the UltraFormattedTextEditor and for the cells where the editor is assigned the cells in the exported excel file defined with font size 11 and the other cells were the editor is null the font size is set to 9.That's why the Editor is set to null for every exported cell. 

To solve the problem I already tried different implementations (all with the same result -> the settings take effect of all exported cells beside the first cell/row):

  • Usage of the WinGridWordWriter
  • Explicit set the font data by usage of WordTableCellSettings

To solve the problem, is there a way to set the default work document font settings? Or is it possible to set the export font data for the Cell Editor Class/Object? Are there any other ways to set the font data for the whole export document?

Thank you for the support!

Parents
No Data
Reply
  • 7535
    Offline posted

    Hello Sabastian,

    Thank you for the post . I looked into the document and find in the CellExporting event through WordTableCellSettings property you can set the cell font , that should help.


    If this dosent help then can you share a small demo sample reproducing the issue.

Children