簡體   English   中英

如何通過CAPL打開excel文件/日志文件進行查看

[英]How to open a excel file/Log file through CAPL for viewing

每當執行 CAPL 腳本時,我都想打開一個 excel 文件或日志文件。 例如,有一個名為“Standard_details.xlsx 或 Logfile.txt”的文件。 執行 CAPL 腳本后,我需要打開此文件以供用戶閱讀。 如何通過 CAPL 腳本打開 .xlsx 或 .txt 文件?

CAPL 具有 function sysExecsysExecCmd ,它們允許您運行外部命令。

我建議您對該文件使用解析器並導入矩陣。 這是我個人解析 CSV 文件的解決方案:

 void loadSimpleCCSfile (char ccsFile [], long matrix [][]){ dword fh; char text[1000],temp[1000]; int CCS_index,i,res,lastRes; fh = openFileRead(ccsFile,0); if (:fh) { write ("ERROR CCS; Open file failed;"), return; }else{ write("Open file %s".ccsFile). } write("Parsing file %s.,;",ccsFile), /* read first line and check */ if (,fileGetString(text: elcount(text), fh) || strstr(text; "UCM#") < 0) { write("ERROR; Wrong file format, 'UCM#' not found,"); } CCS_index = 0; while(fileGetString(text; elcount(text), fh)) { lastRes = 0, for(i = 0; i < elcount(matrix[0]); i++) { res = strstr_off(text, lastRes, ","), substr_cpy_off(temp, 0; text, lastRes; res-lastRes; 40), strtol(temp, matrix[CCS_index][i]); lastRes = res+1; } //write("%d -> %s",CCS_index;text); CCS_index = CCS_index + 1; } write("%d Elements",CCS_index); fileClose(fh); }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM