in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Formats from OwnerDraw-Assigned Styles not Sent to SaveExcel

Last post 02-21-2008 3:11 PM by rsNickel. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 01-14-2008 1:31 PM

    Formats from OwnerDraw-Assigned Styles not Sent to SaveExcel

    We are looking at implementing C1FlexGrid version 2.6.20073.357.

    We found that when a cell's style is assigned during the OwnerDraw event, the formatting that is displayed on the grid is not exported to an Excel file. Cells whose styles were assigned outside of the OwnerDraw event are exported with the formatting defined in the styles.

    In ZIP file:
    GridColors.doc - screen shots of problem
    Grid Project - sample VB project to demo problem

  • 02-05-2008 12:15 PM In reply to

    Re: Formats from OwnerDraw-Assigned Styles not Sent to SaveExcel

    Any news on this one?  We have customers waiting for this.

     Thanks,

    Dave

  • 02-21-2008 1:55 PM In reply to

    • C1_GregL
    • Top 10 Contributor
    • Joined on 06-11-2007
    • Pittsburgh PA
    • Posts 500

    Re: Formats from OwnerDraw-Assigned Styles not Sent to SaveExcel

    The problem is that OwnerDrawCell is only fired for visible cells on the form.  If you were using SetCellStyle in OwnerDrawcell, then that method is never called for cells that are never made visible on the form, so off-screen cells are never assigned a style.  Using "None" and "AsDisplayed" for the FileFlag in SaveExcel() should carry over styles for all cells assigned a style.

    So a workaround is to manually set the styles yourself before calling SaveExcel.  If using SetCellStyle, you can reproduce the same behavior of OwnerDrawnCell outside that event and force it on all cells by just cycling through every cells checking and applying the style(s).  Or you can just call the OwnerDrawCell event manually for each cell prior to saving to Excel:

    Dim g As Graphics = C1FlexGrid1.CreateGraphics
    For r As Integer = 1 To C1FlexGrid1.Rows.Count - 1
     
    For c As Integer = 0 To C1FlexGrid1.Cols.Count - 1

    C1FlexGrid1_OwnerDrawCell(C1FlexGrid1, New C1.Win.C1FlexGrid.OwnerDrawCellEventArgs(C1FlexGrid1, g, r, c, C1FlexGrid1.GetCellStyle(r, c), C1FlexGrid1.GetCellRect(r, c, False), C1FlexGrid1.Item(r, c), C1FlexGrid1.GetCellImage(r, c)))

      Next
    Next

    C1FlexGrid1.SaveExcel("C:\flexformat.xls", "Sheet1", FileFlags.None) 
    Hope that helps,
    - Greg L
    Filed under: ,
  • 02-21-2008 3:11 PM In reply to

    Re: Formats from OwnerDraw-Assigned Styles not Sent to SaveExcel

    We have actually, of late, avoided the assigning of styles in OwnerDrawCell, doing it instead when the cell is first populated. When we started testing 2.6.20073.357, we noticed that some of the formatting were not being sent to Excel and found that it was from earlier forms in our system that assigned styles in OwnerDrawCell.

    The problem was not present in 2.5.20053.233 (see Excel export and screen shots in attached XLS).

    It would be most desirable if 2.6.20073.357 could be made to behave as in the older version.

    I would discuss your solution with the rest of the team back here.
     

    Filed under: ,
Page 1 of 1 (4 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.