Patch level : 10.0
Files correlati : ve0.exe Ricompilazione Demo : [ ] Commento : 0001300: Esportazione Exel Su tutti i documenti l'esportazione in exel crea il file senza mettere l'intestazione delle colonne git-svn-id: svn://10.65.10.50/trunk@18908 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
4f15ade556
commit
f5448cd9e1
@ -3504,6 +3504,19 @@ void TSheet_field::set_userput(SHEET_USERGETPUT handler)
|
||||
_userput = handler;
|
||||
}
|
||||
|
||||
static TString& clean_white_space(TString& str)
|
||||
{
|
||||
str.trim();
|
||||
char* buff = str.get_buffer();
|
||||
for (char* b = buff; *b; b++)
|
||||
{
|
||||
if (*b > '\0' && *b < ' ')
|
||||
*b = ' ';
|
||||
}
|
||||
str.strip_double_spaces();
|
||||
return str;
|
||||
}
|
||||
|
||||
bool TSheet_field::esporta() const
|
||||
{
|
||||
TFilename name;
|
||||
@ -3514,27 +3527,28 @@ bool TSheet_field::esporta() const
|
||||
ofstream xls(name);
|
||||
const char sep = '\t';
|
||||
TToken_string tab(128, sep);
|
||||
|
||||
TString str;
|
||||
|
||||
int columns = 0;
|
||||
for (columns = 0; ; columns++)
|
||||
XI_OBJ** pcols = xi_get_member_list(_ctl->xi_object(), &columns);
|
||||
|
||||
for (int c = 1; c < columns; c++)
|
||||
{
|
||||
str = get_column_header(columns);
|
||||
if (str.not_empty())
|
||||
tab.add(str);
|
||||
else
|
||||
break;
|
||||
xi_get_text(pcols[c], str.get_buffer(), str.size());
|
||||
tab.add(clean_white_space(str));
|
||||
}
|
||||
|
||||
xls << tab << endl;
|
||||
|
||||
for (long n = 0; n < items(); n++)
|
||||
{
|
||||
const TToken_string& r = ((TSheet_field*)this)->row(n);
|
||||
tab = r;
|
||||
tab.replace(r.separator(), sep);
|
||||
tab.separator(sep);
|
||||
for (int c = 0; tab.get(c, str); c++)
|
||||
tab.cut(0);
|
||||
for (int c = 1; c < columns; c++)
|
||||
{
|
||||
const int idx = cid2index(pcols[c]->cid);
|
||||
r.get(idx, str);
|
||||
clean_white_space(str);
|
||||
if (real::is_real(str))
|
||||
{
|
||||
if (real::is_null(str))
|
||||
@ -3546,8 +3560,9 @@ bool TSheet_field::esporta() const
|
||||
else
|
||||
xvt_str_number_format(str.get_buffer(), str.size());
|
||||
}
|
||||
tab.add(str, c);
|
||||
}
|
||||
if (str.not_empty())
|
||||
tab.add(str, c-1);
|
||||
}
|
||||
xls << tab << endl;
|
||||
}
|
||||
|
@ -1337,6 +1337,19 @@ bool TSheet::tutti_handler(TMask_field& f, KEY k)
|
||||
return true;
|
||||
}
|
||||
|
||||
static TString& clean_white_space(TString& str)
|
||||
{
|
||||
str.trim();
|
||||
char* buff = str.get_buffer();
|
||||
for (char* b = buff; *b; b++)
|
||||
{
|
||||
if (*b > '\0' && *b < ' ')
|
||||
*b = ' ';
|
||||
}
|
||||
str.strip_double_spaces();
|
||||
return str;
|
||||
}
|
||||
|
||||
bool TSheet::export_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (k == K_SPACE)
|
||||
@ -1367,42 +1380,32 @@ bool TSheet::export_handler(TMask_field& f, KEY k)
|
||||
const char sep = '\t';
|
||||
TToken_string tab(128, sep);
|
||||
|
||||
TString80 str;
|
||||
TString str;
|
||||
|
||||
int columns = 0;
|
||||
for (columns = 0; ; columns++)
|
||||
XI_OBJ** pcols = xi_get_member_list(s._sheet->xi_object(), &columns);
|
||||
for (int c = 1; c < columns; c++)
|
||||
{
|
||||
if (s._sheet->head(columns, str))
|
||||
{
|
||||
if (str.replace('\n', ' ') > 0)
|
||||
str.strip_double_spaces();
|
||||
tab.add(str);
|
||||
}
|
||||
else
|
||||
break;
|
||||
xi_get_text(pcols[c], str.get_buffer(), str.size());
|
||||
tab.add(clean_white_space(str));
|
||||
}
|
||||
xls << tab << endl;
|
||||
|
||||
for (long i = 0; i < s.items(); i++)
|
||||
{
|
||||
tab = s.row(i);
|
||||
tab.replace('|', sep);
|
||||
tab.separator(sep);
|
||||
for (int c = 0; c < columns; c++)
|
||||
const TToken_string& r = s.row(i);
|
||||
tab.cut(0);
|
||||
for (int c = 1; c < columns; c++)
|
||||
{
|
||||
const char ct = s._sheet->column_type(c);
|
||||
if (ct == 'P' || ct == 'V')
|
||||
const int idx = pcols[c]->cid - 1101;
|
||||
r.get(idx, str);
|
||||
clean_white_space(str);
|
||||
if (str.not_empty())
|
||||
{
|
||||
tab.get(c, str);
|
||||
if (str.full())
|
||||
{
|
||||
if (real::is_natural(str))
|
||||
str.trim();
|
||||
else
|
||||
xvt_str_number_format(str.get_buffer(), str.size());
|
||||
}
|
||||
else
|
||||
str.cut(0);
|
||||
tab.add(str, c);
|
||||
const char ct = s._sheet->column_type(idx);
|
||||
if (ct == 'P' || ct == 'V')
|
||||
xvt_str_number_format(str.get_buffer(), str.size());
|
||||
tab.add(str, c-1);
|
||||
}
|
||||
}
|
||||
xls << tab << endl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user