如何通过CAPL打开excel文件/Log文件进行查看

问题描述

每当执行 CAPL 脚本时,我都想打开一个 excel 文件或日志文件。 例如,有一个名为“Standard_details.xlsx 或 Logfile.txt”的文件。执行 CAPL 脚本后,我需要打开此文件用户阅读。如何通过 CAPL 脚本打开 .xlsx 或 .txt 文件

解决方法

CAPL 具有 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,fh))
    { 
        lastRes = 0;
        for(i = 0; i < elcount(matrix[0]); i++)
        {
            res = strstr_off(text,lastRes,";");
            substr_cpy_off(temp,text,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);
}