1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67:
| function TExcelFile.WriteTipPlanData(TPData: TTipPlanData; Caption, SheetName: String; TipCharCount: PTipCharCount): Cardinal; var Sheet: Variant; p: PSheetData; Col, Row, i, j: Integer; WaitResult: Cardinal; Arr: TArray3b; begin WaitResult := WaitForSingleObject(fWriteTipPlanDataSem, SEMAPHORE_WAIT_TIME); try case WaitResult of WAIT_OBJECT_0: begin WAIT_TIMEOUT: begin result := EXCEL_FILE_WAIT_FOR_SEM_TIMEOUT; end; else result := EXCEL_FILE_WAIT_FOR_SEM_ERROR; end; finally if not ReleaseSemaphore(fWriteTipPlanDataSem, 1, nil) then result := EXCEL_FILE_RELEASE_SEM_ERROR; end; end;
procedure TExcelFile.Save(Filename: String); begin fWorkbook.SaveAs(Filename); end;
constructor TExcelFile.Create(ReqTipChars: TTipPlan; GameCount: Byte); begin inherited Create;
fWriteTipPlanDataSem := CreateSemaphore(nil, 1, 1, ''); CoInitializeEx(nil, COINIT_MULTITHREADED); fExcel := CreateOleObject('Excel.Application'); fExcel.Application.SheetsInNewWorkBook := 1; fExcel.Workbooks.Add; fWorkbook := fExcel.Workbooks[1]; end;
destructor TExcelFile.Destroy; var i: Integer; begin for i := 1 to fExcel.Workbooks.Count do fExcel.Workbooks[i].Close(False); fExcel.Quit; inherited Destroy; end; |