Skip to content
Permalink
Browse files

Add saveAs XLSX and ODS

  • Loading branch information
Patrick Valsecchi
Patrick Valsecchi committed Jan 13, 2016
1 parent b2cc309 commit 9dc7662e17bcb4376c4924bd60599deea082dcc7
Showing with 65 additions and 0 deletions.
  1. +65 −0 src/core/qgsvectorfilewriter.cpp
@@ -1544,6 +1544,57 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
layerOptions
)
);

// XLSX
datasetOptions.clear();
layerOptions.clear();

layerOptions.insert( "OGR_XLSX_FIELD_TYPES", new SetOption(
QObject::tr( "By default, the driver will try to detect the data type of fields. If set "
"to STRING, all fields will be of String type." ),
QStringList()
<< "AUTO"
<< "STRING",
"AUTO", // Default value
false // Allow None
) );

driverMetadata.insert( "XLSX",
MetaData(
"MS Office Open XML spreadsheet",
QObject::tr( "MS Office Open XML spreadsheet" ),
"*.xlsx",
"xlsx",
datasetOptions,
layerOptions
)
);

// ODS
datasetOptions.clear();
layerOptions.clear();

layerOptions.insert( "OGR_ODS_FIELD_TYPES", new SetOption(
QObject::tr( "By default, the driver will try to detect the data type of fields. If set "
"to STRING, all fields will be of String type." ),
QStringList()
<< "AUTO"
<< "STRING",
"AUTO", // Default value
false // Allow None
) );

driverMetadata.insert( "ODS",
MetaData(
"Open Document Spreadsheet",
QObject::tr( "Open Document Spreadsheet" ),
"*.ods",
"ods",
datasetOptions,
layerOptions
)
);

return driverMetadata;
}

@@ -2514,6 +2565,20 @@ bool QgsVectorFileWriter::driverMetadata( const QString& driverName, QString &lo
glob = "*.gdb";
ext = "gdb";
}
else if ( driverName.startsWith( "XLSX" ) )
{
longName = "MS Office Open XML spreadsheet [XLSX]";
trLongName = QObject::tr( "MS Office Open XML spreadsheet [XLSX]" );
glob = "*.xlsx";
ext = "xlsx";
}
else if ( driverName.startsWith( "ODS" ) )
{
longName = "Open Document Spreadsheet";
trLongName = QObject::tr( "Open Document Spreadsheet [ODS]" );
glob = "*.ods";
ext = "ods";
}
else
{
return false;

0 comments on commit 9dc7662

Please sign in to comment.
You can’t perform that action at this time.