Patch level : 10.0

Files correlati     : pd6342.exe pd6342500a.msk
Ricompilazione Demo : [ ]
Commento            :
Migliorata esportazione excel.  Ora puo' esportare le formule sia in inglese sia in italiano.


git-svn-id: svn://10.65.10.50/branches/R_10_00@21149 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2010-11-18 11:51:32 +00:00
parent 25713ad656
commit 425e9e5fea
3 changed files with 77 additions and 35 deletions

View File

@ -4,7 +4,6 @@
#include <defmask.h>
#include <progind.h>
#include <textset.h>
#include <utility.h>
#include "pd6342500a.h"
#include "../ca/calib01.h"
@ -15,15 +14,13 @@
#include "../ca/saldana.h"
#include "../ve/velib.h"
#define FIRST_ROW 5
#define FIRST_COL 2
#define CHAR_RANGE ('Z' - 'A' + 1)
#define ROW2SHEET(r) (FIRST_ROW + r)
COLOR header_back[] = {COLOR_CADETBLUE, COLOR_GREEN, COLOR_BLUE, COLOR_GREY, COLOR_SALMON, COLOR_YELLOW} ;
const COLOR header_back[] = {COLOR_CADETBLUE, COLOR_GREEN, COLOR_BLUE, COLOR_GREY, COLOR_SALMON, COLOR_YELLOW} ;
static const char * col2string(int col)
{
@ -49,6 +46,17 @@ static const char * stringify(TString & s)
return s;
}
bool _english_excel = false;
static const TString& sum_formula(int ci, int ri, int cf, int rf)
{
TString& tmp = get_tmp_string();
tmp << '=' << (_english_excel ? "SUM" : "SOMMA") << '('
<< col2string(ci) << ROW2SHEET(ri) << ':'
<< col2string(cf) << ROW2SHEET(rf) << ')';
return tmp;
}
class TBilancio_recset : public TCSV_recordset
{
int dett_length;
@ -75,11 +83,16 @@ bool TBilancio_recset::get_attr(int column, TAttributes & attr, bool header) con
{
if (column > 1)
{
if ((unsigned int) column >= columns() - 1)
attr.set_background(COLOR_RED);
else
attr.set_background(header_back[_group[column - 2] % 6]);
attr.set_foreground(COLOR_WHITE);
COLOR bkg = COLOR_RED;
if ((unsigned int)column < columns() - 1)
{
const int header_colors = sizeof(header_back) / sizeof(header_back[0]);
bkg = header_back[_group[column-2] % header_colors];
}
COLOR frg = (grayed_color(bkg)&0xFF)>0x80 ? COLOR_BLACK : COLOR_WHITE;
attr.set_background(bkg);
attr.set_foreground(frg);
return true;
}
else
@ -112,6 +125,8 @@ bool TBilancio_recset::get_attr(int column, TAttributes & attr, bool header) con
TBilancio_recset::TBilancio_recset(const TMask & m) : TCSV_recordset("CSV(;)\n")
{
set_separator(';');
_english_excel = m.get_bool(F_INGLESE);
TString esercizio = m.get(F_ANNO);
const TDate al = m.get_date(F_ADATA);
@ -211,13 +226,14 @@ TBilancio_recset::TBilancio_recset(const TMask & m) : TCSV_recordset("CSV(;)\n")
set(ncols + 2, " ");
long start_rec = -1;
int nrows = rowkeys.items();
TProgind p(nrows * 2, "Calcolo Saldi");
const int nrows = rowkeys.items();
TProgind p(nrows * 2, TR("Calcolo Saldi"));
TAnal_bill bill;
for (int r = 0; r < nrows; r++)
{
p.addstatus(1L);
if (!p.addstatus(1))
break;
conto = rowkeys.row(r);
conto = conto.left(dett_length);
bill.set_conto(conto);
@ -229,8 +245,10 @@ TBilancio_recset::TBilancio_recset(const TMask & m) : TCSV_recordset("CSV(;)\n")
set(0, last_conto.left(tot_length));
set(1, cache().get(LF_PCONANA, last_conto.left(tot_length), PCONANA_DESCR));
for (int i = 0; i < ncols - 1; i++)
set(i + 2, format("=SUM(%s%d:%s%d)", col2string(i), ROW2SHEET(start_rec), col2string(i), ROW2SHEET(sheet_row - 1)));
set(ncols + 2, format("=SUM(%s%d:%s%d)", col2string(0), ROW2SHEET(sheet_row), col2string(ncols - 1), ROW2SHEET(sheet_row)));
set(i+2, sum_formula(i, start_rec, i, sheet_row-1));
set(ncols+2, sum_formula(0, sheet_row, ncols-1, sheet_row));
_tot_rows.set(sheet_row);
new_rec();
}
@ -250,10 +268,13 @@ TBilancio_recset::TBilancio_recset(const TMask & m) : TCSV_recordset("CSV(;)\n")
TImporto imp = saldo._ini;
imp += saldo._dare;
imp += saldo._avere;
imp.normalize('A');
set(c + 2, imp.valore());
if (!imp.is_zero())
{
imp.normalize('A');
set(c + 2, imp.valore());
}
}
set(ncols + 2, format("=SUM(%s%d:%s%d)", col2string(0), ROW2SHEET(sheet_row), col2string(ncols - 1), ROW2SHEET(sheet_row)));
set(ncols + 2, sum_formula(0, sheet_row, ncols-1, sheet_row));
}
if (start_rec != -1)
{
@ -261,22 +282,24 @@ TBilancio_recset::TBilancio_recset(const TMask & m) : TCSV_recordset("CSV(;)\n")
set(0, last_conto.left(tot_length));
set(1, cache().get(LF_PCONANA, last_conto.left(tot_length), PCONANA_DESCR));
for (int i = 0; i < ncols - 1; i++)
set(i + 2, format("=SUM(%s%d:%s%d)", col2string(i), ROW2SHEET(start_rec), col2string(i), ROW2SHEET(sheet_row - 1)));
set(ncols + 2, format("=SUM(%s%d:%s%d)", col2string(0), ROW2SHEET(sheet_row), col2string(ncols - 1), ROW2SHEET(sheet_row)));
set(i + 2, sum_formula(i, start_rec, i, sheet_row-1));
set(ncols + 2, sum_formula(0, sheet_row, ncols-1, sheet_row));
_tot_rows.set(sheet_row);
new_rec();
}
sheet_row = new_rec() ;
set(1, "Totale Diretti");
TString expr;
for (int c = 0; c < ncols; c++)
{
TString expr;
expr.cut(0);
for (int j = _tot_rows.first_one(); j <= _tot_rows.last_one(); j++)
if (_tot_rows[j])
expr << ((j == _tot_rows.first_one()) ? '=' : '+') << col2string(c) << ROW2SHEET(j);
set(c + 2, expr);
set(ncols + 2, format("=SUM(%s%d:%s%d)", col2string(0), ROW2SHEET(sheet_row), col2string(ncols - 1), ROW2SHEET(sheet_row)));
set(ncols + 2, sum_formula(0, sheet_row, ncols - 1,sheet_row));
}
_tot_gen.set(sheet_row);
new_rec();
@ -285,7 +308,8 @@ TBilancio_recset::TBilancio_recset(const TMask & m) : TCSV_recordset("CSV(;)\n")
last_conto.cut(0);
for (int r = 0; r < nrows; r++)
{
p.addstatus(1L);
if (!p.addstatus(1L))
break;
conto = rowkeys.row(r);
conto = conto.left(dett_length);
bill.set_conto(conto);
@ -297,8 +321,8 @@ TBilancio_recset::TBilancio_recset(const TMask & m) : TCSV_recordset("CSV(;)\n")
set(0, last_conto.left(tot_length));
set(1, cache().get(LF_PCONANA, last_conto.left(tot_length), PCONANA_DESCR));
for (int i = 0; i < ncols - 1; i++)
set(i + 2, format("=SUM(%s%d:%s%d)", col2string(i), ROW2SHEET(start_rec), col2string(i), ROW2SHEET(sheet_row - 1)));
set(ncols + 2, format("=SUM(%s%d:%s%d)", col2string(0), ROW2SHEET(sheet_row), col2string(ncols - 1), ROW2SHEET(sheet_row)));
set(i + 2, sum_formula(i, start_rec, i,sheet_row-1));
set(ncols + 2, sum_formula(0, sheet_row, ncols - 1,sheet_row));
_tot_rows_ind.set(sheet_row);
new_rec();
}
@ -318,10 +342,13 @@ TBilancio_recset::TBilancio_recset(const TMask & m) : TCSV_recordset("CSV(;)\n")
TImporto imp = saldo._ini;
imp += saldo._dare;
imp += saldo._avere;
imp.normalize('A');
set(c + 2, imp.valore());
if (!imp.is_zero())
{
imp.normalize('A');
set(c + 2, imp.valore());
}
}
set(ncols + 2, format("=SUM(%s%d:%s%d)", col2string(0), ROW2SHEET(sheet_row), col2string(ncols - 1), ROW2SHEET(sheet_row)));
set(ncols + 2, sum_formula(0, sheet_row, ncols - 1,sheet_row));
}
if (start_rec != -1)
{
@ -329,8 +356,8 @@ TBilancio_recset::TBilancio_recset(const TMask & m) : TCSV_recordset("CSV(;)\n")
set(0, last_conto.left(tot_length));
set(1, cache().get(LF_PCONANA, last_conto.left(tot_length), PCONANA_DESCR));
for (int i = 0; i < ncols - 1; i++)
set(i + 2, format("=SUM(%s%d:%s%d)", col2string(i), ROW2SHEET(start_rec), col2string(i), ROW2SHEET(sheet_row - 1)));
set(ncols + 2, format("=SUM(%s%d:%s%d)", col2string(0), ROW2SHEET(sheet_row), col2string(ncols - 1), ROW2SHEET(sheet_row)));
set(i + 2, sum_formula(i, start_rec, i,sheet_row-1));
set(ncols + 2, sum_formula(0, sheet_row, ncols - 1,sheet_row));
_tot_rows_ind.set(sheet_row);
new_rec();
}
@ -345,7 +372,7 @@ TBilancio_recset::TBilancio_recset(const TMask & m) : TCSV_recordset("CSV(;)\n")
expr << ((j == _tot_rows_ind.first_one()) ? '=' : '+') << col2string(c) << ROW2SHEET(j);
set(c + 2, expr);
}
set(ncols + 2, format("=SUM(%s%d:%s%d)", col2string(0), ROW2SHEET(sheet_row), col2string(ncols - 1), ROW2SHEET(sheet_row)));
set(ncols + 2, sum_formula(0, sheet_row, ncols - 1,sheet_row));
_tot_gen.set(sheet_row);
new_rec();
sheet_row = new_rec();
@ -359,7 +386,7 @@ TBilancio_recset::TBilancio_recset(const TMask & m) : TCSV_recordset("CSV(;)\n")
expr << ((j == _tot_gen.first_one()) ? '=' : '+') << col2string(c) << ROW2SHEET(j);
set(c + 2, expr);
}
set(ncols + 2, format("=SUM(%s%d:%s%d)", col2string(0), ROW2SHEET(sheet_row), col2string(ncols - 1), ROW2SHEET(sheet_row)));
set(ncols + 2, sum_formula(0, sheet_row, ncols - 1,sheet_row));
_tot_fin = sheet_row;
}
@ -413,7 +440,10 @@ void TSaldi_ana_app::main_loop()
fname.add(m.get(F_NAME));
if (fname.full())
{
b.save_as(fname, fmt_unknown);
xvt_sys_goto_url(fname, "open");
}
}
}

View File

@ -4,7 +4,7 @@
#define F_PATH 103
#define F_NAME 104
#define F_TIPO 105
#define F_INGLESE 106
#define COLOR_GREY 0x545454
#define COLOR_SILVER 0xC0C0C0

View File

@ -2,7 +2,14 @@
TOOLBAR "topbar" 0 0 0 2
#include <elabar.h>
BUTTON DLG_OK 2 2
BEGIN
PROMPT 1 1 "Elabora"
PICTURE TOOL_EXCEL
END
#include <helpbar.h>
ENDPAGE
@ -55,7 +62,7 @@ BEGIN
PROMPT 41 4 "Al "
END
GROUPBOX DLG_NULL 78 4
GROUPBOX DLG_NULL 78 5
BEGIN
PROMPT 1 7 "@bFoglio Excel del calcolo"
END
@ -72,5 +79,10 @@ BEGIN
FSELECT "*.xls"
END
BOOLEAN F_INGLESE
BEGIN
PROMPT 2 10 "Esportazione formule in inglese (es: SOMMA -> SUM)"
END
ENDPAGE
ENDMASK