void WriteSymbolsTableToXLS(const SymbolsTable& symbolsTable, const char* filepath) { BasicExcel xlsFile; BasicExcelWorksheet* worksheet = xlsFile.AddWorksheet("Symbols"); worksheet->Cell(0, 0)->Set(L"Classes ->"); int row = 1; for (map<string, SymbolClass>::const_iterator curClass = symbolsTable.begin(), lastClass = symbolsTable.end(); curClass != lastClass; ++curClass) { worksheet->Cell(row, 0)->Set(curClass->second.name.c_str()); if (curClass->second.functions.empty()) { row += 2; continue; } worksheet->Cell(row + 2, 0)->Set(L"Methods ->"); worksheet->Cell(row + 2, 1)->Set(L"Modifier"); worksheet->Cell(row + 2, 2)->Set(L"Return type"); worksheet->Cell(row + 2, 3)->Set(L"Name"); worksheet->Cell(row + 2, 4)->Set(L"Parameters"); row += 3; for (auto curFunction : curClass->second.functions) { worksheet->Cell(row, 1)->Set(curFunction.second.modifier.c_str()); worksheet->Cell(row, 2)->Set(curFunction.second.returnType.c_str()); worksheet->Cell(row, 3)->Set(curFunction.second.name.c_str()); int parameterIndex = 0; for (auto curParameter = curFunction.second.parameters.begin(), lastParameter = curFunction.second.parameters.end(); curParameter != lastParameter; ++curParameter) { worksheet->Cell(row, 4 + parameterIndex)->Set((curParameter->second.name + ": " + curParameter->second.type).c_str()); ++parameterIndex; } worksheet->Cell(row + 1, 0)->Set(L"Blocks ->"); ++row; for (auto curBlock = curFunction.second.blocks.begin(), lastBlock = curFunction.second.blocks.end(); curBlock != lastBlock; ++curBlock) { WriteBlocksToXLS(worksheet, row, 1, *curBlock); ++row; } ++row; } ++row; } worksheet->SetColWidth(0, 15000); worksheet->SetColWidth(1, 15000); xlsFile.SaveAs(filepath); }
std::string VLDDexporter::CommandProcessor::RunCommands(InputProcessor& data){ // let's run filters on the input data // _FilterInputData(data); // run the routine with the loaded parameters // // output spreadsheet // BasicExcel xls; // workbook sheets: // hot files, hot functions, summary, leaked blocks xls.New(4); // create hot files sheet // BasicExcelWorksheet* hotfilessheet = xls.GetWorksheet(0); hotfilessheet->Rename("Hot files"); // hot functions sheet // BasicExcelWorksheet* hotfunctions = xls.GetWorksheet(1); hotfunctions->Rename("Hot functions"); // summary sheet // //BasicExcelWorksheet* summarysheet = xls.GetWorksheet(2); //summarysheet->Rename("Summary"); // leaked blocks // //BasicExcelWorksheet* leakedblocks = xls.GetWorksheet(3); //leakedblocks->Rename("Leaked blocks"); XLSFormatManager fmt_mgr(xls); // create required fonts // ExcelFont fontheader; fontheader._weight = FW_BOLD; //fontheader._color_index = ExcelFont fontdata; fontheader._weight = FW_NORMAL; CellFormat fmtheader(fmt_mgr); fmtheader.set_font(fontheader); CellFormat fmtdata(fmt_mgr); fmtdata.set_font(fontdata); int Row = 0; int Col = 0; // hot files // for(Col = 0; Col < 4; Col++){ // get current cell // BasicExcelCell* cell = hotfilessheet->Cell(Row, Col); switch(Col){ case 0: { cell->Set("File"); } break; case 1: { cell->Set("Blame count"); } break; case 2: { cell->Set("Lines"); } break; case 3: { cell->Set("Blame gathering function"); } break; } cell->SetFormat(fmtheader); } // set proper widths // hotfilessheet->SetColWidth(0, 24000); hotfilessheet->SetColWidth(1, 5000); hotfilessheet->SetColWidth(2, 6000); hotfilessheet->SetColWidth(3, 10000); // output data // for(size_t i = 0; i < data.LeakingFiles.size(); i++){ // increase row // Row++; CallstackFileEntry* file = data.LeakingFiles[i].get(); for(Col = 0; Col < 4; Col++){ // get current cell // BasicExcelCell* cell = hotfilessheet->Cell(Row, Col); switch(Col){ case 0: { cell->Set(file->PathOrName.c_str()); } break; case 1: { cell->SetInteger(file->BlameCount); } break; case 2: { string lines; for(size_t a = 0; a < file->LeakLines.size(); a++){ if(a != 0) lines += ", "; stringstream converter; converter << file->LeakLines[a]; string tmpstr = ""; converter >> tmpstr; lines += tmpstr; } cell->Set(lines.c_str()); } break; case 3: { cell->Set(file->FunctionsInfile[0]->Name.c_str()); } break; } cell->SetFormat(fmtdata); } } Row = 0; Col = 0; // output hot functions // for(Col = 0; Col < 4; Col++){ // get current cell // BasicExcelCell* cell = hotfunctions->Cell(Row, Col); switch(Col){ case 0: { cell->Set("Function"); } break; case 1: { cell->Set("Blame count"); } break; case 2: { cell->Set("File"); } break; case 3: { cell->Set("Line"); } break; } cell->SetFormat(fmtheader); } // set proper widths // hotfunctions->SetColWidth(0, 32000); hotfunctions->SetColWidth(1, 5000); hotfunctions->SetColWidth(2, 24000); // output data // for(size_t i = 0; i < data.LeakingFunctions.size(); i++){ // increase row // Row++; CallstackFunction* func = data.LeakingFunctions[i].get(); for(Col = 0; Col < 4; Col++){ // get current cell // BasicExcelCell* cell = hotfunctions->Cell(Row, Col); switch(Col){ case 0: { cell->Set(func->Name.c_str()); } break; case 1: { cell->SetInteger(func->BlameCount); } break; case 2: { cell->Set(func->ContainedInFile->PathOrName.c_str()); } break; case 3: { cell->SetInteger(func->Line); } break; } cell->SetFormat(fmtdata); } } string finaloutput = OutputFilePath+OutputFile; // delete old first // wstringstream sstream; sstream << finaloutput.c_str(); wstring path; sstream >> path; DeleteFile((L"\\\\?\\"+path).c_str()); // save file // xls.SaveAs(finaloutput.c_str()); // return the created output // return OutputFilePath+OutputFile; }
void network_generator::write_output(){ for(int k=0;k<channel_layer;k++){ BasicExcel xls; // create sheet 1 and get the associated BasicExcelWorksheet pointer xls.New(1); BasicExcelWorksheet* sheet = xls.GetWorksheet(0); XLSFormatManager fmt_mgr(xls); // Create a table containing an header row in bold and four rows below. ExcelFont font_bold; font_bold._weight = FW_BOLD; // 700 CellFormat fmt_bold(fmt_mgr); fmt_bold.set_font(font_bold); ExcelFont font_red_bold; font_red_bold._weight = FW_BOLD; font_red_bold._color_index = EGA_BLACK; CellFormat color_1(fmt_mgr, font_red_bold); color_1.set_color1(COLOR1_PAT_SOLID); color_1.set_color2(MAKE_COLOR2(29,0)); CellFormat color_2(fmt_mgr, font_red_bold); color_2.set_color1(COLOR1_PAT_SOLID); color_2.set_color2(MAKE_COLOR2(16,0)); for (int i=0;i<101;i++){ for(int j=0;j<101;j++){ BasicExcelCell* cell = sheet->Cell(i, j); if(i%2 == 0 && j%2 == 0){ cell->SetFormat(color_2); sheet->Cell(i, j)->Set(-1); } else{ cell->SetFormat(color_1); sheet->Cell(i, j)->Set(liquid_network[k][i][j]); } } } for (int i=0;i<101;i++){ sheet->SetColWidth(i,950); } char layernum = k+48; string test_case_num = "0"; test_case_num += char(chip.case_num+48); string output_name=""; output_name += "cada030_problemA_testcase"; output_name += test_case_num; if(channel_layer > 1){ output_name += "_channellayer"; output_name += layernum; } output_name += ".xls"; xls.SaveAs(&output_name[0]); } }