labwindows/CVI excel报表

生成报表按钮回调函数

static CAObjHandle applicationHandle = 0;
static CAObjHandle workbookHandle = 0;
static CAObjHandle worksheetHandle = 0;
static excel_row_count=0;
int CVICALLBACK report_excel (int panel, int control, int event,
							  void *callbackData, int eventData1, int eventData2)
{
	int error;
	char strBuf[20]={0};
	double data[10]={1.213,2.254}   ;
	switch (event)
	{
		case EVENT_COMMIT:
			error = ExcelRpt_ApplicationNew(1, &applicationHandle);  
			if (error<0) 
			{
        		//MessagePopup (APP_AUTOMATION_ERR, LAUNCHERR);
                		goto Error;
			}
	 		ExcelRpt_WorkbookNew(applicationHandle, &workbookHandle);
	    	ExcelRpt_WorksheetNew(workbookHandle, -1, &worksheetHandle);
		SetCtrlAttribute (panelHandle, PANEL_REPORT_BUTTON, ATTR_DIMMED, 1);
		sprintf(strBuf,"%s%d","A",++excel_row_count); //格式化字符串
		SetCtrlVal(panelHandle,PANEL_RECEIVE_MESSAGE,strBuf);
	        ExcelRpt_WriteData (worksheetHandle, strBuf, CAVT_DOUBLE, 1, 1, data);  
		break;
	}
Error:
	return 0;
}


注意事项: 需要加入excelreport.fp

参考文献:“在LabWindows_CVI中输出EXCEL报表”

你可能感兴趣的:(CVI)