// 出力 if ( LOWORD(wParam) == IDC_CHECK ) { GetMessageString( "0103" ); if ( Dlg->MsgYesNo( Message ) ) { Tool.WaitCursor( true ); CurApp->DataOut(); Tool.WaitCursor( false ); } }
// ********************************************************* // 出力実行 // ********************************************************* BOOL App_01::DataOut( void ) { BOOL bRet; BOOL bFirst; int nBase; int nPage; if ( !CurDb->Connect() ) { Dlg->MsgOk("データベースの接続に失敗しました "); return false; } // 選択されたシート名の取得 SheetName->SelectedGetText( Item ); // 新しいブックにシートをコピー(元のブックは閉じます) ExcelApp->CopySheet( Item ); nBase = 1; nPage = 1; Work->Printf( "ページ%d", nPage ); // 印字用のシートをコピー(同じブック内、nBaseの前にコピー) ExcelApp->CopySheet( nBase, Work ); Query->operator = ("select * from 商品分類マスタ order by 商品分類"); bRet = CurDb->Query( Query ); bFirst = true; while( bRet ) { if ( bFirst ) { bFirst = false; this->HeadPrint(); } if ( this->nRow > this->nRowMax ) { nPage++; Work->Printf( "ページ%d", nPage ); // 印字用のシートをコピー nBase = ExcelApp->SheetCount(); ExcelApp->CopySheet( nBase, Work ); this->HeadPrint(); } this->DetailPrint(); bRet = CurDb->Query( ); } CurDb->DisConnect(); // Excel をいったん保存 Tool.ProgramDirectory( Buff->szLboxString ); Buff->AddBackslash(); Buff->operator += ( "HP711.xls" ); ExcelApp->Save( Buff ); // カレントのブックを閉じます ExcelApp->Quit(); // 元Excel を開く Dlg->EditGetText( IDC_EXCEL, Work ); ExcelApp->Open( Work ); // Excel を起動 Dlg->Executable( Buff, Work ); Work->Enclose( "\"" ); Work->operator += (" "); Buff->Enclose( "\"" ); Work->operator += (Buff); Tool.Execute( Work, NULL ); return true; }
// ********************************************************* // タイトル部出力 // ********************************************************* void App_01::HeadPrint( void ) { // 1行目 nRow = 1; Buff->operator = ("** 商品分類一覧 **"); ExcelApp->SetCell( 3, nRow, Buff ); // 3行目 nRow = 3; Buff->operator = ("商品分類"); ExcelApp->SetCell( 1, nRow, Buff ); Buff->operator = ("名 称"); ExcelApp->SetCell( 2, nRow, Buff ); // 4行目 nRow = 4; Work->Repeat( "-", 53 ); Buff->operator = (Work); ExcelApp->SetCell( 1, nRow, Buff ); // 次に出力する行 this->nRow = 5; }
// ********************************************************* // 明細部出力 // ********************************************************* void App_01::DetailPrint( void ) { CurDb->GetText( "商品分類", Item ); ExcelApp->SetCell( 1, nRow, Item ); CurDb->GetText( "名称", Item ); ExcelApp->SetCell( 2, nRow, Item ); (this->nRow)++; }