⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 report.c

📁 这是我编写的深圳地铁S335型司机控制器的检测程序
💻 C
📖 第 1 页 / 共 2 页
字号:
   error = Excel_WorksheetRange (ExcelWorksheetHandle, NULL, CellRange, CA_DEFAULT_VAL, &ExcelRangeHandle);
   CA_VariantClear (&CellRange);
   if (error < 0) goto Error;
   // Make range Active    
   error = Excel_RangeActivate (ExcelRangeHandle, NULL, NULL);
   if (error<0) goto Error;

   return 0;   
Error:    
   if (error < 0) 
      ReportAppAutomationError (error);
   return error;
}

//------------------------------------------------------------------------------------------------
int __stdcall ExcelSetReportValue( void )
{
   char        chData[ 128 ];
   int         i;
   LPT_MeasureData   pData;
   pData = &g_SystemData.ptMeasureData;

//   sprintf( chData, "%04d/%02d/%02d %02d:%02d:%02d", pData->ptStart.wYear, pData->ptStart.wMonth, pData->ptStart.wDay, pData->ptStart.wHour, pData->ptStart.wMinute, pData->ptStart.wSecond );
   ExcelCellSetValue (2, 3, pData->ptDevice.acDriverControllerID);
   ExcelCellSetValue (3, 2, pData->ptDevice.acFactoryDate);
   ExcelCellSetValue (3, 4, pData->ptDevice.acheckerName);
   sprintf (chData, "%.1f℃", g_SystemData.ptDAQData.fTemperature);
   ExcelCellSetValue (3, 6, chData);
   ExcelCellSetValue (3, 8, pData->ptDevice.acVID);
   
   sprintf (chData, "%04d.%02d.%02d", g_SystemData.ptMeasureData.ptStartTime.wYear,
      g_SystemData.ptMeasureData.ptStartTime.wMonth, g_SystemData.ptMeasureData.ptStartTime.wDay);
   ExcelCellSetValue (2, 8, chData);
   
   for (i = 0; i < 13; i ++)
   {
      sprintf (chData, "%.0f", pData->ptResister [i].fResister);
      ExcelCellSetValue (16 + i, 3, chData);
   }
   for (i = 0; i < 12; i ++)
   {
      sprintf (chData, "%.0f", pData->ptResister [13 + i].fResister);
      ExcelCellSetValue (16 + i, 7, chData);
   }
   
   sprintf (chData, "%.3f", pData->ptPosition [0].fVoltage);
   ExcelCellSetValue (34, 3, chData);
   sprintf (chData, "%.3f", pData->ptPosition [2].fVoltage);
   ExcelCellSetValue (33, 3, chData);
   sprintf (chData, "%.3f", pData->ptPosition [4].fVoltage);
   ExcelCellSetValue (35, 3, chData);
   sprintf (chData, "%.3f", pData->ptPosition [5].fVoltage);
   ExcelCellSetValue (36, 3, chData);
   
   sprintf (chData, "%.3f", pData->ptPosition [6].fVoltage);
   ExcelCellSetValue (32, 3, chData);

   sprintf (chData, "%.3f", pData->ptPosition [8].fVoltage);
   ExcelCellSetValue (33, 7, chData);
   sprintf (chData, "%.3f", pData->ptPosition [10].fVoltage);
   ExcelCellSetValue (32, 7, chData);
   sprintf (chData, "%.3f", pData->ptPosition [12].fVoltage);
   ExcelCellSetValue (34, 7, chData);
   sprintf (chData, "%.3f", pData->ptPosition [13].fVoltage);
   ExcelCellSetValue (35, 7, chData);
   
   i = 39;
   sprintf (chData, "%.3f", pData->ptForceData [0].fForce);
   ExcelCellSetValue (i + 0, 5, chData);
   sprintf (chData, "%.3f", pData->ptForceData [1].fForce);
   ExcelCellSetValue (i + 1, 5, chData);
   sprintf (chData, "%.3f", pData->ptForceData [2].fForce);
   ExcelCellSetValue (i + 2, 5, chData);
   sprintf (chData, "%.3f", pData->ptForceData [3].fForce);
   ExcelCellSetValue (i + 3, 5, chData);
   sprintf (chData, "%.3f", pData->ptForceData [4].fForce);
   ExcelCellSetValue (i + 4, 5, chData);
   sprintf (chData, "%.3f", pData->ptForceData [5].fForce);
   ExcelCellSetValue (i + 5, 5, chData);
   sprintf (chData, "%.3f", pData->ptForceData [6].fForce);
   ExcelCellSetValue (i + 7, 5, chData);
   sprintf (chData, "%.3f", pData->ptForceData [7].fForce);
   ExcelCellSetValue (i + 8, 5, chData);
   sprintf (chData, "%.3f", pData->ptForceData [8].fForce);
   ExcelCellSetValue (i + 9, 5, chData);
   sprintf (chData, "%.3f", pData->ptForceData [9].fForce);
   ExcelCellSetValue (i + 10, 5, chData);
   sprintf (chData, "%.3f", pData->ptForceData [10].fForce);
   ExcelCellSetValue (i + 12, 5, chData);
   
   return 0;
}

//------------------------------------------------------------------------------------------------
int __stdcall ExcelSetReportResult(void)
{
   char        chData[ 128 ];
   
   int         i;
   short       usResister = 0;
   short       usPosition = 0;
   LPT_MeasureData   pData;
   pData = &g_SystemData.ptMeasureData;
   
   if (pData->ptPosition [6].usChecked == 1)
      ExcelCellSetValue (7, 3, "√");
   else
      ExcelCellSetValue (7, 3, "×");

   if (pData->ptPosition [7].usChecked == 1)
      ExcelCellSetValue (7, 7, "√");
   else
      ExcelCellSetValue (7, 7, "×");

   if (pData->ptPosition [0].usChecked == 1)
      ExcelCellSetValue (8, 3, "√");
   else
      ExcelCellSetValue (8, 3, "×");
   if (pData->ptPosition [1].usChecked == 1)
      ExcelCellSetValue (9, 3, "√");
   else
      ExcelCellSetValue (9, 3, "×");
   if (pData->ptPosition [2].usChecked == 1)
      ExcelCellSetValue (10, 3, "√");
   else
      ExcelCellSetValue (10, 3, "×");
   if (pData->ptPosition [3].usChecked == 1)
      ExcelCellSetValue (11, 3, "√");
   else
      ExcelCellSetValue (11, 3, "×");
   if (pData->ptPosition [4].usChecked == 1)
      ExcelCellSetValue (12, 3, "√");
   else
      ExcelCellSetValue (12, 3, "×");
   if (pData->ptPosition [5].usChecked == 1)
      ExcelCellSetValue (13, 3, "√");
   else
      ExcelCellSetValue (13, 3, "×");

   if (pData->ptPosition [8].usChecked == 1)
      ExcelCellSetValue (8, 7, "√");
   else
      ExcelCellSetValue (8, 7, "×");
   if (pData->ptPosition [9].usChecked == 1)
      ExcelCellSetValue (9, 7, "√");
   else
      ExcelCellSetValue (9, 7, "×");
   if (pData->ptPosition [10].usChecked == 1)
      ExcelCellSetValue (10, 7, "√");
   else
      ExcelCellSetValue (10, 7, "×");
   if (pData->ptPosition [11].usChecked == 1)
      ExcelCellSetValue (11, 7, "√");
   else
      ExcelCellSetValue (11, 7, "×");
   if (pData->ptPosition [12].usChecked == 1)
      ExcelCellSetValue (12, 7, "√");
   else
      ExcelCellSetValue (12, 7, "×");
   if (pData->ptPosition [13].usChecked == 1)
      ExcelCellSetValue (13, 7, "√");
   else
      ExcelCellSetValue (13, 7, "×");

   return 0;
}

//------------------------------------------------------------------------------------------------
int __stdcall QLReportCheck(void)
{
   if (g_SystemData.ptMeasureData.ptStartTime.wYear == 0)
   {
      MessageBox (NULL, "测试数据无效!", "错误", MB_OK | MB_ICONERROR | MB_TOPMOST );
      return -1;
   }

   return 0;
}

//------------------------------------------------------------------------------------------------
int __stdcall _ReportCreate(int nPrint)
{
   HRESULT     hrStatus;
   char chData[ 256 ];
   char chFileName[512];
   char chTitle[128];
   
//   if (QLReportCheck () < 0)
//      return -1;
   if (nPrint == 1)
   {
      sprintf (chData, "E:\\Report\\Print.xls");
   }
   else
   {
      strcpy (chTitle, "保存报表");
      sprintf (chData, "%04d%02d%02d-%s.xls", g_SystemData.ptMeasureData.ptStartTime.wYear,
         g_SystemData.ptMeasureData.ptStartTime.wMonth, g_SystemData.ptMeasureData.ptStartTime.wDay,
         g_SystemData.ptMeasureData.ptDevice.acVID);
      
      if (FileSelectPopup ("E:\\Report\\", chData, "*.xls", chTitle, VAL_SAVE_BUTTON, 0, 1, 1, 1, chFileName) <= 0)
         return -1;
   }

   if (ExcelOpen ())
      return -1;
   
   if (ExcelCreate ("E:\\Project_DriverController\\Data\\Record.xlt", chFileName))
      return -1;
         
   if (ExcelSetReportValue ())
      return -1;
   if (ExcelSetReportResult ())
      return -1;
   
   return 0;
}

//------------------------------------------------------------------------------------------------
int __stdcall ReportRefresh(void)
{
   if (ExcelSetReportValue ())
      return -1;
   if (ExcelSetReportResult ())
      return -1;
   
   return 0;
}


//------------------------------------------------------------------------------------------------
int __stdcall ReportClose(void)
{
   if (ExcelClose ())
      return 0;
   return 0;
}
   
//------------------------------------------------------------------------------------------------
int __stdcall ReportCreate(void)
{
   if (_ReportCreate (0) == -1)
      return -1;
   
   if (ExcelSave ())
      return -1;
   
   return 0;
}

//------------------------------------------------------------------------------------------------
int __stdcall ReportSave(void)
{
   if (ExcelSave ())
      return -1;
   return 0;
}

//------------------------------------------------------------------------------------------------
int __stdcall ReportShow(void)
{
   if (ExcelShow ())
      return -1;
   
   return 0;
}

//------------------------------------------------------------------------------------------------
int __stdcall ReportPrint( void )
{
   if (ExcelPrint ())
      return -1;

   return 0;
}

//------------------------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -