1

I'm working on someone else's code where they're building a TcxGrid without going through the visual editor. I will be exporting that grid to excel so I need to set the column type to TcxSpinEdit (contents are all numbers).

How can I set the property? I tried with PropertyClass and PropertyClassName but none of them work (I still get the "number as text" warning in excel).

This is the relevant part:

var
Stolpec: TcxGridDBColumn;

[...]

if CheckBoxStevilkoMultiTime.Checked    then
    begin
      Stolpec := cxGrid1DBTableView3.CreateColumn;
      Stolpec.DataBinding.FieldName := 'STVLK_INI_C';
      Stolpec.Width := larghCol;
      Stolpec.FooterAlignmentHorz := taRightJustify;
      Stolpec.GroupSummaryAlignment := taRightJustify;
      Stolpec.Name := 'cxGrid1DBTableView3' + Colonna.DataBinding.FieldName;
      TcxGridDBTableSummaryItem(cxGrid1DBTableView3.DataController.Summary.DefaultGroupSummaryItems[5]).Column := Stolpec;
      TcxGridDBTableSummaryItem(cxGrid1DBTableView3.DataController.Summary.DefaultGroupSummaryItems[5]).Position := posIndx;
      Stolpec.Caption := 'Stevilko';
      Stolpec.Options.Editing := False;
    end;
asg2012
  • 315
  • 1
  • 6
  • 15

1 Answers1

2
uses
   cxSpinEdit;

...
  Stolpec.PropertiesClass := TcxSpinEditProperties;
  TcxSpinEditProperties(Stolpec.Properties).MaxValue:= 10;
...
Ravaut123
  • 2,764
  • 31
  • 46
  • If you want to export the grid to excel you can use the procedure ExportToExcel from unit cxGridExportLink – Ravaut123 Aug 22 '12 at 10:52
  • Thanks. I'm already using ExportGridToExcel() but the problem is that several numeral columns end up being written as text in excel and the user then needs to change this before being able to do calculations. – asg2012 Aug 22 '12 at 12:25
  • In the Procedure ExportToExcel I set the AUseNativeFormat to true.And can you set the Stolpec.Databinding.ValueType to Integer or other numeric type – Ravaut123 Aug 22 '12 at 12:44