cxSpreadBook 或 cxSpreadSheet 設置成文本格式
來源:程序員人生 發布時間:2014-11-11 08:55:06 閱讀次數:3491次
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;
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈