Skip to content

Commit

Permalink
XLSX: declare OLCStringsAsUTF8 on newly created layers
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Feb 24, 2024
1 parent e9c6bcf commit 2e95631
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions autotest/ogr/ogr_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def ogr_xlsx_check(ds):

assert lyr.TestCapability("foo") == 0

assert lyr.TestCapability(ogr.OLCStringsAsUTF8) == 1

lyr = ds.GetLayer(6)
assert lyr.GetName() == "Feuille7", "bad layer name"

Expand Down Expand Up @@ -277,6 +279,7 @@ def test_ogr_xlsx_8():

ds = ogr.GetDriverByName("XLSX").CreateDataSource("/vsimem/ogr_xlsx_8.xlsx")
lyr = ds.CreateLayer("foo")
assert lyr.TestCapability(ogr.OLCStringsAsUTF8) == 1
for i in range(30):
lyr.CreateField(ogr.FieldDefn("Field%d" % (i + 1)))
f = ogr.Feature(lyr.GetLayerDefn())
Expand Down
2 changes: 1 addition & 1 deletion ogr/ogrsf_frmts/xlsx/ogrxlsxdatasource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ OGRXLSXLayer::OGRXLSXLayer(OGRXLSXDataSource *poDSIn, const char *pszFilename,
poDS(poDSIn), osFilename(pszFilename), bUpdated(CPL_TO_BOOL(bUpdatedIn)),
bHasHeaderLine(false)
{
SetAdvertizeUTF8(true);
}

/************************************************************************/
Expand Down Expand Up @@ -822,7 +823,6 @@ void OGRXLSXDataSource::endElementTable(CPL_UNUSED const char *pszNameIn)
if (poCurLayer)
{
((OGRMemLayer *)poCurLayer)->SetUpdatable(CPL_TO_BOOL(bUpdatable));
((OGRMemLayer *)poCurLayer)->SetAdvertizeUTF8(true);
((OGRXLSXLayer *)poCurLayer)->SetUpdated(false);
}

Expand Down

0 comments on commit 2e95631

Please sign in to comment.