Skip to content
Permalink
Browse files

Merge pull request #2670 from pvalsecc/xlsx_ods

Add saveAs XLSX and ODS
  • Loading branch information
nyalldawson committed Jan 13, 2016
2 parents 184db1a + 9dc7662 commit 31d981c49c01bfe824e61272e5308c882dcea1cf
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 31d981c

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