Home Forums WinForms controls Xceed Grid for WinForms CellDataFormat in ExcelExporter

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15352 |

    Using the ExcelExporter class to produce an xls of results after prompting the user with a dialog for where to save the file etc.

    My grid contains a mix of string, and numeric data. In the resulting grid I want numeric data cells to be formatted numerically, so that operations can be performed on those columns thereafter.

    However, turning the CellDataFormat property to Value causes an exception. I’m guessing that by changing the property from DisplayText to Value means that all data in the grid must be numeric. I’m really hoping this isn’t the case and I’m actually missing something else.

    Additionally, I have hooked into various events that the ExcelExporter class offers, but none of the breakpoints I’ve placed in the handlers appear to fire up as my spreadsheet is written. I’d hoped that examining the way the events fire, seeing what data I could obtain inside them might aid me in changing the data format of cells ‘on the fly’ so that specific cells could be formatted numerically.

    Can’t find a great deal of information on how to achieve this sort of thing in the documentation/examples, any pointers?

    Much appreciated!

    Imported from legacy forums. Posted by matt (had 7446 views)

    User (Old forums)
    Member
    Post count: 23064

    Ignore what I said about the events firing, I missed something in code – apologies!

    I’ll investigate using those now and see what I can find.

    Imported from legacy forums. Posted by matt (had 344 views)

    User (Old forums)
    Member
    Post count: 23064

    I tried changing the CellDataFormat while in the export process, from a handle to the WritingCell event on the ExcelExport object.

    The exception I get if I try this is “Property setters or methods cannot be called when the component is currently exporting.”. Ok, so I can’t change the property when work has begun, I’ve established that.

    So back to my question – is it possible to format the spreadsheet cells according to the data contained in the grid (part numeric, part text). Like I said before, if I use CellDataFormat.Value I keep getting an exception, and I’m assuming that’s down to the grid containing text as well as numeric data.

    Thanks.

    Imported from legacy forums. Posted by matt (had 294 views)

    User (Old forums)
    Member
    Post count: 23064

    Setting CellDataFormat to Value means that the data will be exported in the type the data is. So if a column is set to string, it will be exported to string. If the next column is set to double, it will be exported to double. Etc… In sum, you should be able to export your numeric columns as such.

    What is the exception you get exactly?

    Imported from legacy forums. Posted by André (had 291 views)

    User (Old forums)
    Member
    Post count: 23064

    I’m ensuring that my columns are instantiated with the correct types but still have the problem. Must be elsewhere.

    The exception I get is “An exception occurred while exporting.” The inner exception is NULL.

    Thanks.

    Imported from legacy forums. Posted by matt (had 349 views)

    User (Old forums)
    Member
    Post count: 23064

    You can send us a sample application that reproduce the issue, and we will investigate this further. We can at least try to improve the exception message that is throw by the grid!

    Imported from legacy forums. Posted by André (had 379 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi again.

    Suspect the problem arises when a cell has data bound to it which is of Nullable type. If any of the bound data in this scenario is null then an exception occurs. For example, I iterate through a List of Nullable<int>. For each of these I add a new DataRow to my GridControl and populate a Cell in that DataRow with the value from my current Nullable<int>. If this value is null then the problem seems to occur during export.

    The missing inner exception details which are being published when the exception “An exception occurred during exporting” is thrown should be reproduced by doing the above. I would be willing to bet that the inner exception is “Object reference not set to an instance of an object.” though.

    Hope this helps fixing the problem.

    Imported from legacy forums. Posted by matt (had 422 views)

    User (Old forums)
    Member
    Post count: 23064

    We can consider this a bug, though the grid itself does not entirely support nullable DataTypes. It will be fixed in our next version (not in the package coming out soon, but the following one).

    You can download it <a href=”http://xceed.com/pages/TopMenu/Downloads/Updates.aspx?Lang=EN-CA”>here</a&gt;.

    Imported from legacy forums. Posted by André (had 498 views)

    User (Old forums)
    Member
    Post count: 23064

    The fix for this issue is now available through our latest release. You can download it from one of the following links :

    <a href=”http://download3.xceedsoft.com/Packages/3.0.7264.16200/XceedComponentsWebInstall.exe”>Web Install</a>

    <a href=”http://download3.xceedsoft.com/Packages/3.0.7264.16200/XceedComponents.exe”>Full Package</a>

    Imported from legacy forums. Posted by André (had 245 views)

    User (Old forums)
    Member
    Post count: 23064

    How do I take advantage of this fix with an older version of the grid (3.2) ?

    Imported from legacy forums. Posted by Natalie (had 449 views)

    User (Old forums)
    Member
    Post count: 23064

    This will be fixed in the next Service Pack for .NET 1.1 components release (not the one released yesterday).

    Imported from legacy forums. Posted by André (had 909 views)

    User (Old forums)
    Member
    Post count: 23064

    The grid was at 3.6 before this was investigated and that doesn’t look like it’s been updated since.

    So if I grab the 3.6 grid again, the Reporting component that bundles has been updated?

    Thanks.

    Imported from legacy forums. Posted by matt (had 390 views)

    User (Old forums)
    Member
    Post count: 23064

    Yes, for version 3.6, the fix is already available.

    Imported from legacy forums. Posted by André (had 8623 views)

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.