# include <stdio.h>
# include <stdlib.h>
#include <math.h>
#include "excel2000.h"
#include "excelreport.h"
#include <cvirte.h>
#include <userint.h>
#include <utility.h>
#include <ansi_c.h>
//static int panelHandle;
static CAObjHandle applicationHandle = 0;
static CAObjHandle workbookHandle = 0;
static CAObjHandle worksheetHandle = 0;
static CAObjHandle workrangeHandle = 0;
VARIANT MyCellRangeV;
ERRORINFO ErrorInfo;
void openxl()
{
ExcelRpt_ApplicationNew(0, &applicationHandle);
ExcelRpt_WorkbookOpen(applicationHandle, "C:\\Users\\7000\\Desktop\\CVI\\offset.xlsx", &workbookHandle);
ExcelRpt_GetWorksheetFromName(workbookHandle, "Sheet1", &worksheetHandle);
}
void closexl()
{
if (worksheetHandle)
CA_DiscardObjHandle(worksheetHandle);
if (workbookHandle)
{
ExcelRpt_WorkbookClose(workbookHandle, 1);
CA_DiscardObjHandle(workbookHandle);
}
if (applicationHandle)
{
ExcelRpt_ApplicationQuit(applicationHandle);
CA_DiscardObjHandle(applicationHandle);
}
}
int main()
{ openxl();
ExcelRpt_SetCellValue(worksheetHandle,"A1",CAVT_CSTRING,"Pass");
CA_VariantSetCString (&MyCellRangeV, "A1:A5");
Excel_WorksheetRange (worksheetHandle, NULL, MyCellRangeV, CA_DEFAULT_VAL, &workrangeHandle);
Excel_RangeMerge (workrangeHandle, NULL, CA_DEFAULT_VAL);
closexl();
// ExcelRpt_GetCellValue(worksheetHandle, "B2", CAVT_DOUBLE, &num);
// printf("%.2f",num);
}
Lab Windows CVI |合并单元格
最新推荐文章于 2023-02-13 17:17:21 发布