Spread export events

17 posts, 0 answers
  1. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 23 Nov 2015 Link to this post

    using CellFormatting event.How can  i setup borders for cells .
                BorderStyles border = new BorderStyles();
                border.Color = Color.Black;
                border.Weight = 1;
                border.LineStyle = LineStyle.Continuous;
                border.PositionType = PositionType.Bottom;
    How can i use this, cause somethng like that :
                e.CellStyleInfo.Borders = border;

    doesn't work.

    In exportML were e.ExcelStyleElement.Borders.Add function, cant find how this must work.

  2. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 23 Nov 2015 Link to this post

    Also nim trying to addheader to created workbook and i can t fo\ind any info about workbook created event, eny request from
    http://www.telerik.com/help/winforms/radgridview-exporting-data-how-to-add-header-and-footer.html or from search cause error.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 23 Nov 2015 in reply to VLADISLAV Link to this post

    Also im trying to add header to created workbook and i cant find any info about workbook created event, any request from
    http://www.telerik.com/help/winforms/radgridview-exporting-data-how-to-add-header-and-footer.html or from search cause error.***
  5. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 23 Nov 2015 Link to this post

    Hello Vladislav,

    Thank you for writing.

    To set the borders, you need to create an object of type CellBorders and assign it to the CellStyleInfo.Borders property. Note that the ExportVisualStyles property of the GridViewSpreadExport should be set to  true.

    Alternatively, you can use the SpreadProcessing API and work with the workbook.

    In regards to inserting rows, again you can utilize the SpreadProcessing API. In this case, you can use the Workbook created event of the renderer, to get the workbook once it is cooked. From there you can perform any manipulations you need.

    Here is an example:
    private void radButton1_Click(object sender, EventArgs e)
    {
        GridViewSpreadExport exporter = new GridViewSpreadExport(radGridView1);
        exporter.CellFormatting += exporter_CellFormatting;
        exporter.ExportVisualSettings = true;
     
        SpreadExportRenderer renderer = new SpreadExportRenderer();
        renderer.WorkbookCreated += renderer_WorkbookCreated;
        exporter.RunExport(@"D:\asd.xlsx", renderer);
    }
     
    void renderer_WorkbookCreated(object sender, WorkbookCreatedEventArgs e)
    {
        Worksheet sheet = (Worksheet)e.Workbook.ActiveSheet;
        if (sheet.Rows.CanInsert(0,1))
        {
            RowSelection selection = sheet.Rows[0];
            selection.Insert();
        }
     
        CellIndex from = new CellIndex(0, 0);
        CellIndex to = new CellIndex(0, 1);
        CellSelection selection1 = sheet.Cells[from, to];
        selection1.Merge();
        selection1.SetValue("lqlqlq");
    }
     
    void exporter_CellFormatting(object sender, Telerik.WinControls.Export.CellFormattingEventArgs e)
    {
        CellBorders borders = new CellBorders();
        borders.Top = new CellBorder(CellBorderStyle.Thin, new ThemableColor(System.Windows.Media.Colors.Red));
        borders.Bottom = new CellBorder(CellBorderStyle.Thin, new ThemableColor(System.Windows.Media.Colors.Red));
        borders.Right = new CellBorder(CellBorderStyle.Thin, new ThemableColor(System.Windows.Media.Colors.Red));
        borders.Left = new CellBorder(CellBorderStyle.Thin, new ThemableColor(System.Windows.Media.Colors.Red));
        e.CellStyleInfo.Borders = borders;
    }

    I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

    Regards,
    Stefan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 23 Nov 2015 Link to this post

    System.Windows.Media.Colors.Red  Cannto resolve symbol Media, and i cant find reference to System.Windows.Media
  7. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 23 Nov 2015 Link to this post

    This type is located in the PresentationCore assembly. Alternatively, you can use the following method to create ThemableColor from ARGB:
    ThemableColor.FromArgb(0, 120, 120, 120);

    Regards,
    Stefan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  8. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 23 Nov 2015 Link to this post

    Thank you.
  9. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 23 Nov 2015 Link to this post

    Workbok created event also merge all SummaryRowsBottom. For all childRows except the last one. And also Total row on top . 
  10. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 23 Nov 2015 in reply to VLADISLAV Link to this post

    Worksheet sheet = (Worksheet)e.Workbook.ActiveSheet;
                if (sheet.Rows.CanInsert(0, 1))
                {
                    RowSelection selection = sheet.Rows[0];
                    selection.Insert();
                }

                CellIndex from = new CellIndex(0, 0);
                CellIndex to = new CellIndex(0, 16);
                CellSelection selection1 = sheet.Cells[from, to];
                selection1.Merge();
                selection1.SetValue("Перечень разных сборов и прочих поступлений.");
                selection1.SetHorizontalAlignment(RadHorizontalAlignment.Center);
                selection1.SetFontSize(24);
  11. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 23 Nov 2015 Link to this post

    Can you please elaborate on the issue you have as I am not sure I understand what is it?

    Regards,
    Stefan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  12. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 23 Nov 2015 Link to this post

     This part deals that.

    if (sheet.Rows.CanInsert(0, 1))
                {
                    RowSelection selection = sheet.Rows[0];
                    selection.Insert();
                }

                CellIndex from = new CellIndex(0, 0);
                CellIndex to = new CellIndex(0, 16);
                CellSelection selection1 = sheet.Cells[from, to];
                selection1.Merge();
                selection1.SetValue("Перечень разных сборов и прочих поступлений.");
                selection1.SetHorizontalAlignment(RadHorizontalAlignment.Center);
                selection1.SetFontSize(24);

  13. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 23 Nov 2015 Link to this post

    Without insert/merge part of this event everything fine ( pic. g16).But if i uncomment this part it gives me pic.g15. It merges also some summaryRows.
  14. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 23 Nov 2015 Link to this post

    And manual Unmerge restores this rows.So they shown as they must.
  15. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 24 Nov 2015 Link to this post

    This happens after this part
                if (sheet.Rows.CanInsert(0, 1))
                {
                    RowSelection selection = sheet.Rows[0];
                    selection.Insert();
                }
    After row insert im getting this strange merges on the summary rows.
  16. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 24 Nov 2015 Link to this post

    Hello Vladislav,

    My guess for such behavior is if you use incorrect indexes where you insert row and where you merge cells. You need to make sure you insert the row at the precise position where you want it, and then, to select the desired cells and merge them. 

    More about rows and column in RadSpreadProcessing you can find in this documentation section: http://www.telerik.com/help/winforms/spreadprocessing-working-with-rows-and-columns-what-is-row-column.html

    And the following section discusses cells and their usage: http://www.telerik.com/help/winforms/spreadprocessing-working-with-cells-what-is-cell.html

    Merging cells is discussed here: http://www.telerik.com/help/winforms/spreadprocessing-features-merge-unmerge-cells.html.

    If you still experience issues, you can send over a small sample (using a support ticket, where attachments are allowed) depicting the issue you have, and we will look into it.

    Regards,
    Stefan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  17. VLADISLAV
    VLADISLAV avatar
    32 posts
    Member since:
    Oct 2015

    Posted 24 Nov 2015 Link to this post

    Created Support ticket
  18. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 24 Nov 2015 Link to this post

    I just wanted to update this thread that we found an issue with the merged rows, which we have logged: http://feedback.telerik.com/Project/154/Feedback/Details/176126-fix-radspreadprocessing-invalid-cells-merge-when-a-row-is-inserted

    To workaround, the issue one can insert the row after the export operation is finished and the file is closed, by opening the file with the format provider and introducing the necessary changes.

    Regards,
    Stefan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WinForms is Visual Studio 2017 Ready