Fix various classification reports in the same excel book
This commit is contained in:
@@ -22,6 +22,27 @@ namespace platform {
|
|||||||
colorOdd = 0xDCE6F1;
|
colorOdd = 0xDCE6F1;
|
||||||
colorEven = 0xFDE9D9;
|
colorEven = 0xFDE9D9;
|
||||||
}
|
}
|
||||||
|
lxw_worksheet* ExcelFile::createWorksheet(const std::string& name)
|
||||||
|
{
|
||||||
|
lxw_worksheet* sheet;
|
||||||
|
std::string suffix = "";
|
||||||
|
std::string efectiveName;
|
||||||
|
int num = 1;
|
||||||
|
// Create a sheet with the name of the model
|
||||||
|
while (true) {
|
||||||
|
efectiveName = name + suffix;
|
||||||
|
if (workbook_get_worksheet_by_name(workbook, efectiveName.c_str())) {
|
||||||
|
suffix = std::to_string(++num);
|
||||||
|
} else {
|
||||||
|
sheet = workbook_add_worksheet(workbook, efectiveName.c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (num > 100) {
|
||||||
|
throw std::invalid_argument("Couldn't create sheet " + efectiveName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sheet;
|
||||||
|
}
|
||||||
|
|
||||||
lxw_workbook* ExcelFile::getWorkbook()
|
lxw_workbook* ExcelFile::getWorkbook()
|
||||||
{
|
{
|
||||||
|
@@ -24,6 +24,7 @@ namespace platform {
|
|||||||
void boldBlue(); //set blue color for the bold styles
|
void boldBlue(); //set blue color for the bold styles
|
||||||
void boldGreen(); //set green color for the bold styles
|
void boldGreen(); //set green color for the bold styles
|
||||||
void createStyle(const std::string& name, lxw_format* style, bool odd);
|
void createStyle(const std::string& name, lxw_format* style, bool odd);
|
||||||
|
lxw_worksheet* createWorksheet(const std::string& name);
|
||||||
void addColor(lxw_format* style, bool odd);
|
void addColor(lxw_format* style, bool odd);
|
||||||
lxw_format* efectiveStyle(const std::string& name);
|
lxw_format* efectiveStyle(const std::string& name);
|
||||||
lxw_workbook* workbook;
|
lxw_workbook* workbook;
|
||||||
|
@@ -17,26 +17,7 @@ namespace platform {
|
|||||||
worksheet_set_column(worksheet, i, i, columns_sizes.at(i), NULL);
|
worksheet_set_column(worksheet, i, i, columns_sizes.at(i), NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ReportExcel::createWorksheet()
|
|
||||||
{
|
|
||||||
const std::string name = data["model"].get<std::string>();
|
|
||||||
std::string suffix = "";
|
|
||||||
std::string efectiveName;
|
|
||||||
int num = 1;
|
|
||||||
// Create a sheet with the name of the model
|
|
||||||
while (true) {
|
|
||||||
efectiveName = name + suffix;
|
|
||||||
if (workbook_get_worksheet_by_name(workbook, efectiveName.c_str())) {
|
|
||||||
suffix = std::to_string(++num);
|
|
||||||
} else {
|
|
||||||
worksheet = workbook_add_worksheet(workbook, efectiveName.c_str());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (num > 100) {
|
|
||||||
throw std::invalid_argument("Couldn't create sheet " + efectiveName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReportExcel::createFile()
|
void ReportExcel::createFile()
|
||||||
{
|
{
|
||||||
@@ -44,7 +25,8 @@ namespace platform {
|
|||||||
workbook = workbook_new((Paths::excel() + Paths::excelResults()).c_str());
|
workbook = workbook_new((Paths::excel() + Paths::excelResults()).c_str());
|
||||||
}
|
}
|
||||||
if (worksheet == NULL) {
|
if (worksheet == NULL) {
|
||||||
createWorksheet();
|
const std::string name = data["model"].get<std::string>();
|
||||||
|
worksheet = createWorksheet(name);
|
||||||
}
|
}
|
||||||
setProperties(data["title"].get<std::string>());
|
setProperties(data["title"].get<std::string>());
|
||||||
formatColumns();
|
formatColumns();
|
||||||
@@ -209,7 +191,8 @@ namespace platform {
|
|||||||
}
|
}
|
||||||
void ReportExcel::create_classification_report(const json& result)
|
void ReportExcel::create_classification_report(const json& result)
|
||||||
{
|
{
|
||||||
auto matrix_sheet = workbook_add_worksheet(workbook, "classif_report");
|
|
||||||
|
auto matrix_sheet = createWorksheet("clf_report");
|
||||||
lxw_worksheet* tmp = worksheet;
|
lxw_worksheet* tmp = worksheet;
|
||||||
worksheet = matrix_sheet;
|
worksheet = matrix_sheet;
|
||||||
if (matrix_sheet == NULL) {
|
if (matrix_sheet == NULL) {
|
||||||
|
@@ -15,7 +15,6 @@ namespace platform {
|
|||||||
private:
|
private:
|
||||||
void formatColumns();
|
void formatColumns();
|
||||||
void createFile();
|
void createFile();
|
||||||
void createWorksheet();
|
|
||||||
void header() override;
|
void header() override;
|
||||||
void body() override;
|
void body() override;
|
||||||
void showSummary() override;
|
void showSummary() override;
|
||||||
|
Reference in New Issue
Block a user