【问题标题】:How to open a excel file/Log file through CAPL for viewing如何通过CAPL打开excel文件/日志文件查看
【发布时间】:2021-04-06 19:45:57
【问题描述】:

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

【问题讨论】:

    标签: excel capl canoe


    【解决方案1】:

    CAPL 有函数sysExecsysExecCmd,允许你运行外部命令。

    【讨论】:

      【解决方案2】:

      我建议您对该文件使用解析器并导入矩阵。 这是我个人解析 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);
      }

      【讨论】:

        猜你喜欢
        • 2021-04-06
        • 1970-01-01
        • 1970-01-01
        • 2023-03-27
        • 1970-01-01
        • 1970-01-01
        • 2022-06-23
        • 2022-06-19
        • 2014-02-05
        相关资源
        最近更新 更多