Patch level :
Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/trunk@20181 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
52ffd1164c
commit
04c645854d
@ -122,11 +122,23 @@ bool TRecordset::save_as_html(const char* path)
|
||||
for (unsigned int c = 0; c < cols; c++)
|
||||
{
|
||||
const TRecordset_column_info& ci = column_info(c);
|
||||
out << " <col align=\""
|
||||
<< (ci._type == _longfld || ci._type == _realfld ? "right" : "left")
|
||||
<< "\">" << endl;
|
||||
out << " <col ";
|
||||
switch (ci._type)
|
||||
{
|
||||
case _intfld :
|
||||
case _longfld:
|
||||
case _realfld: out << "align=\"right\""; break;
|
||||
case _boolfld: out << "align=\"center\""; break;
|
||||
default : out << "style=\"mso-number-format:\\@\""; break;
|
||||
}
|
||||
out << " />" << endl;
|
||||
}
|
||||
out << " <tr>" << endl;
|
||||
|
||||
TXmlItem tr; tr.SetTag("tr");
|
||||
tr.SetColorAttr("bgcolor", BTN_BACK_COLOR);
|
||||
tr.Write(out, 2);
|
||||
out << endl;
|
||||
|
||||
for (unsigned int c = 0; c < cols; c++)
|
||||
{
|
||||
const TRecordset_column_info& ci = column_info(c);
|
||||
@ -150,21 +162,36 @@ bool TRecordset::save_as_html(const char* path)
|
||||
{
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
|
||||
out << " <tr>" << endl;
|
||||
for (unsigned int c = 0; c < cols; c++)
|
||||
{
|
||||
const TRecordset_column_info& ci = column_info(c);
|
||||
out << " <td>";
|
||||
if (ci._type == _longfld || ci._type == _realfld)
|
||||
switch (ci._type)
|
||||
{
|
||||
const real r = get(c).as_real();
|
||||
if (r.is_zero())
|
||||
case _intfld:
|
||||
case _longfld:
|
||||
{
|
||||
const long r = get(c).as_int();
|
||||
val.cut(0);
|
||||
else
|
||||
val = r.stringe();
|
||||
if (r != 0)
|
||||
val << r;
|
||||
}
|
||||
break;
|
||||
case _realfld:
|
||||
{
|
||||
const real r = get(c).as_real();
|
||||
if (r.is_zero())
|
||||
val.cut(0);
|
||||
else
|
||||
val = r.stringe();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
get(c).as_string(val);
|
||||
break;
|
||||
}
|
||||
else
|
||||
get(c).as_string(val);
|
||||
if (val.full())
|
||||
{
|
||||
val.rtrim();
|
||||
@ -182,82 +209,6 @@ bool TRecordset::save_as_html(const char* path)
|
||||
return !pi.iscancelled();
|
||||
}
|
||||
|
||||
bool TRecordset::save_as_silk(const char* path)
|
||||
{
|
||||
TProgind pi(items(), TR("Esportazione in corso..."), true, true);
|
||||
|
||||
ofstream out(path);
|
||||
out << "ID;PWXL;N;E" << endl;
|
||||
|
||||
const unsigned int cols = columns();
|
||||
|
||||
int header = 1;
|
||||
if (cols > 0)
|
||||
{
|
||||
// Larghezza colonne
|
||||
for (unsigned int h = 0; h < cols; h++)
|
||||
{
|
||||
const TRecordset_column_info& ci = column_info(h);
|
||||
const int w = max(ci._width, ci._name.len());
|
||||
out << "F;W" << (h+1) << ' ' << (h+1) << ' ' << w << endl;
|
||||
}
|
||||
|
||||
// Intestazioni colonne
|
||||
for (unsigned int c = 0; c < cols; c++)
|
||||
{
|
||||
const TRecordset_column_info& ci = column_info(c);
|
||||
out << 'C';
|
||||
if (c == 0) out << ";Y1";
|
||||
out << ";X" << (c+1) << ";K\"" << ci._name << '"' << endl;
|
||||
}
|
||||
header++;
|
||||
}
|
||||
|
||||
TString val;
|
||||
for (bool ok = move_first(); ok; ok = move_next())
|
||||
{
|
||||
for (unsigned int c = 0; ; c++)
|
||||
{
|
||||
const TVariant& var = get(c);
|
||||
if (var.is_null() && c >= cols)
|
||||
break;
|
||||
|
||||
out << 'C';
|
||||
if (c == 0) out << ";Y" << (current_row()+header);
|
||||
if (!var.is_empty())
|
||||
{
|
||||
out << ";X" << (c+1) << ";K";
|
||||
var.as_string(val);
|
||||
switch (var.type())
|
||||
{
|
||||
case _alfafld:
|
||||
case _datefld:
|
||||
if (cols == 0 && is_numeric(val))
|
||||
{
|
||||
out << val;
|
||||
}
|
||||
else
|
||||
{
|
||||
val.rtrim();
|
||||
val.replace('"', '\'');
|
||||
out << '"' << val << '"';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
out << val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
out << endl;
|
||||
}
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
}
|
||||
out << "E" << endl;
|
||||
|
||||
return !pi.iscancelled();
|
||||
}
|
||||
|
||||
bool TRecordset::save_as_text(const char* path)
|
||||
{
|
||||
TProgind pi(items(), TR("Esportazione in corso..."), true, true);
|
||||
@ -459,16 +410,13 @@ bool TRecordset::save_as(const char* path, TRecordsetExportFormat fmt, int mode)
|
||||
TString ext;
|
||||
xvt_fsys_parse_pathname(path, NULL, NULL, NULL, ext.get_buffer(), NULL);
|
||||
ext.lower();
|
||||
if (ext == "htm" || ext == "html" || ext == "xml")
|
||||
fmt = fmt_html; else
|
||||
if (ext == "xls" || ext == "slk")
|
||||
fmt = fmt_silk;
|
||||
if (ext == "htm" || ext == "html" || ext == "xml" || ext == "xls")
|
||||
fmt = fmt_html;
|
||||
}
|
||||
bool ok = false;
|
||||
switch (fmt)
|
||||
{
|
||||
case fmt_html : ok = save_as_html(path); break;
|
||||
case fmt_silk : ok = save_as_silk(path); break;
|
||||
case fmt_campo: ok = save_as_campo(path); break;
|
||||
case fmt_dbf : ok = save_as_dbf(path, mode); break;
|
||||
default : ok = save_as_text(path); break;
|
||||
|
@ -26,7 +26,7 @@ struct TRecordset_column_info : public TObject
|
||||
// TRecordset
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
enum TRecordsetExportFormat { fmt_unknown, fmt_html, fmt_text, fmt_silk, fmt_campo, fmt_dbf };
|
||||
enum TRecordsetExportFormat { fmt_unknown, fmt_html, fmt_text, fmt_campo, fmt_dbf };
|
||||
|
||||
class TRecordset : public TObject
|
||||
{
|
||||
|
@ -1386,11 +1386,24 @@ bool TSheet::export_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
const int idx = pcols[c]->cid - 1101;
|
||||
const char ct = s._sheet->column_type(idx);
|
||||
xls << " <col align=\"" << (strchr("PRV", ct) ? "right" : "left") << "\">" << endl;
|
||||
TXmlItem col; col.SetTag("col");
|
||||
switch (ct)
|
||||
{
|
||||
case 'C': col.SetAttr("align", "center"); break;
|
||||
case 'P':
|
||||
case 'R':
|
||||
case 'V': col.SetAttr("align", "right"); break;
|
||||
default : col.SetAttr("style", "mso-number-format:\\@"); break;
|
||||
}
|
||||
col.Write(xls, 3);
|
||||
xls << endl;
|
||||
}
|
||||
|
||||
xls << " <tr>" << endl;
|
||||
|
||||
TXmlItem tr; tr.SetTag("tr");
|
||||
tr.SetColorAttr("bgcolor", BTN_BACK_COLOR);
|
||||
tr.Write(xls, 3);
|
||||
xls << endl;
|
||||
|
||||
TString str;
|
||||
for (int c = 1; c < columns; c++)
|
||||
{
|
||||
|
@ -165,6 +165,13 @@ TXmlItem& TXmlItem::SetAttr(const char* strAttr, int n)
|
||||
return SetAttr(strAttr, str);
|
||||
}
|
||||
|
||||
TXmlItem& TXmlItem::SetColorAttr(const char* strAttr, COLOR rgb)
|
||||
{
|
||||
TString8 str;
|
||||
str.format("#%02X%02X%02X", XVT_COLOR_GET_RED(rgb), XVT_COLOR_GET_GREEN(rgb), XVT_COLOR_GET_BLUE(rgb));
|
||||
return SetAttr(strAttr, str);
|
||||
}
|
||||
|
||||
int TXmlItem::GetIntAttr(const char* strAttr, int def) const
|
||||
{
|
||||
const TString& str = GetAttr(strAttr);
|
||||
@ -587,9 +594,9 @@ void save_html_head(ostream& out, const char* title)
|
||||
{
|
||||
out << "<head>" << endl;
|
||||
out << " <title>" << title << "</title>" << endl;
|
||||
out << " <meta name=\"author\" content=\"" << user() << "\" />" << endl;
|
||||
out << " <meta name=\"application\" content=\"" << dongle().product() << "\"/>" << endl;
|
||||
out << " <meta name=\"vendor\" content=\"" << dongle().reseller() << "\"/>" << endl;
|
||||
out << " <meta name=Author content=\"" << user() << "\" />" << endl;
|
||||
out << " <meta name=Generator content=\"" << dongle().product() << "\"/>" << endl;
|
||||
out << " <meta name=Vendor content=\"" << dongle().reseller() << "\"/>" << endl;
|
||||
out << " <style type=\"text/css\">" << endl;
|
||||
out << " th = { background-color:"; WriteXmlColor(out, BTN_BACK_COLOR); out << " }" << endl;
|
||||
out << " </style>" << endl;
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
TXmlItem& SetAttr(const char* strAttr, const char* strVal);
|
||||
const TString& GetAttr(const char* strAttr) const;
|
||||
TXmlItem& SetAttr(const char* strAttr, int n);
|
||||
TXmlItem& SetColorAttr(const char* strAttr, COLOR rgb);
|
||||
int GetIntAttr(const char* strAttr, int def = 0) const;
|
||||
TXmlItem& SetAttr(const char* strAttr, bool yes);
|
||||
bool GetBoolAttr(const char* strAttr) const;
|
||||
@ -78,6 +79,7 @@ public:
|
||||
TXmlItem& operator<<(TXmlItem& item, const char* str);
|
||||
void Spaces(ostream& outf, int nSpaces);
|
||||
void WriteXmlString(ostream& outf, const char* str);
|
||||
void WriteXmlColor(ostream& outf, COLOR rgb);
|
||||
int hex2int(const char* str);
|
||||
void save_html_head(ostream& out, const char* title);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user