diff --git a/include/recset.cpp b/include/recset.cpp
index 5e571be06..4b5e5638d 100755
--- a/include/recset.cpp
+++ b/include/recset.cpp
@@ -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 << "
" << endl;
for (unsigned int c = 0; c < cols; c++)
{
const TRecordset_column_info& ci = column_info(c);
out << " ";
- 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;
diff --git a/include/recset.h b/include/recset.h
index dbacda7cf..7ed36e091 100755
--- a/include/recset.h
+++ b/include/recset.h
@@ -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
{
diff --git a/include/sheet.cpp b/include/sheet.cpp
index bbeb1165e..c9aa6a6ad 100755
--- a/include/sheet.cpp
+++ b/include/sheet.cpp
@@ -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 << " " << 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 << " |