码迷,mamicode.com
首页 > 数据库 > 详细

cxSpreadBook 或 cxSpreadSheet 设置成文本格式

时间:2014-10-31 11:57:20      阅读:332      评论:0      收藏:0      [点我收藏+]

标签:des   style   ar   for   sp   on   cti   bs   ad   

uses

     cxSSStyles,cxSSDesigner;


Type 

  TStyleAccess = class(TcxSSCellStyle);
  TSheetAccess = class(TcxSSBookSheet);


procedure TForm2.Button16Click(Sender: TObject);

var
  Row,Col: Integer;
  AStyle: TcxSSCellStyle;
  CurrentStyle: integer;
begin 
  TSheetAccess(cxSpreadBook.ActiveSheet).Owner.BeginUpdate;
  try
    for Row := 0 to cxSpreadBook.ActiveSheet.RowCount - 1 do
      for Col := 0 to cxSpreadBook.ActiveSheet.ColumnCount - 1 do
      begin
        AStyle :=  cxSpreadBook.ActiveSheet.GetCellObject(Col,row).Style;
        CurrentStyle := TStyleAccess(AStyle).StyleInfo.FormatIndex;
        if  CurrentStyle =0 then  //像那些时间类型的 不能强制转换成文本 不然会出错 
        begin
          TStyleAccess(AStyle).StyleInfo.FormatIndex := 49;
          TStyleAccess(AStyle).DoOnChange(AStyle, siFormat);
        end;
      end;
  finally
    TSheetAccess(cxSpreadBook.ActiveSheet).Owner.EndUpdate;
  end;

end;


cxSpreadBook 或 cxSpreadSheet 设置成文本格式

标签:des   style   ar   for   sp   on   cti   bs   ad   

原文地址:http://blog.csdn.net/dongzi502/article/details/40651553

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!