cxSpreadBook 或 cxSpreadSheet 设置成文本格式
uses
cxSSStyles,cxSSDesigner;
Type
TStyleAccess = class(TcxSSCellStyle);
TSheetAccess = class(TcxSSBookSheet);
procedure TForm2.Button16Click(Sender: TObject);
varRow,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;
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。