From 7da2247e40f23a2a423f794e356436f227b60de9 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Sun, 26 Feb 2017 10:47:26 +0500 Subject: Safely name sheets for excel reports --- src/org/traccar/reports/Events.java | 3 ++- src/org/traccar/reports/Route.java | 3 ++- src/org/traccar/reports/Trips.java | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/org/traccar/reports/Events.java b/src/org/traccar/reports/Events.java index 33893aad0..d2255684f 100644 --- a/src/org/traccar/reports/Events.java +++ b/src/org/traccar/reports/Events.java @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; +import org.apache.poi.ss.util.WorkbookUtil; import org.joda.time.DateTime; import org.jxls.area.Area; import org.jxls.builder.xls.XlsCommentAreaBuilder; @@ -98,7 +99,7 @@ public final class Events { DeviceReport deviceEvents = new DeviceReport(); Device device = Context.getIdentityManager().getDeviceById(deviceId); deviceEvents.setDeviceName(device.getName()); - sheetNames.add(deviceEvents.getDeviceName()); + sheetNames.add(WorkbookUtil.createSafeSheetName(deviceEvents.getDeviceName())); if (device.getGroupId() != 0) { Group group = Context.getDeviceManager().getGroupById(device.getGroupId()); if (group != null) { diff --git a/src/org/traccar/reports/Route.java b/src/org/traccar/reports/Route.java index 468771a48..c1acaf322 100644 --- a/src/org/traccar/reports/Route.java +++ b/src/org/traccar/reports/Route.java @@ -26,6 +26,7 @@ import java.util.Collection; import java.util.Date; import java.util.List; +import org.apache.poi.ss.util.WorkbookUtil; import org.joda.time.DateTime; import org.jxls.area.Area; import org.jxls.builder.xls.XlsCommentAreaBuilder; @@ -67,7 +68,7 @@ public final class Route { DeviceReport deviceRoutes = new DeviceReport(); Device device = Context.getIdentityManager().getDeviceById(deviceId); deviceRoutes.setDeviceName(device.getName()); - sheetNames.add(deviceRoutes.getDeviceName()); + sheetNames.add(WorkbookUtil.createSafeSheetName(deviceRoutes.getDeviceName())); if (device.getGroupId() != 0) { Group group = Context.getDeviceManager().getGroupById(device.getGroupId()); if (group != null) { diff --git a/src/org/traccar/reports/Trips.java b/src/org/traccar/reports/Trips.java index a52d48f16..45b52b63c 100644 --- a/src/org/traccar/reports/Trips.java +++ b/src/org/traccar/reports/Trips.java @@ -26,6 +26,7 @@ import java.util.Collection; import java.util.Date; import java.util.List; +import org.apache.poi.ss.util.WorkbookUtil; import org.joda.time.DateTime; import org.jxls.area.Area; import org.jxls.builder.xls.XlsCommentAreaBuilder; @@ -201,7 +202,7 @@ public final class Trips { DeviceReport deviceTrips = new DeviceReport(); Device device = Context.getIdentityManager().getDeviceById(deviceId); deviceTrips.setDeviceName(device.getName()); - sheetNames.add(deviceTrips.getDeviceName()); + sheetNames.add(WorkbookUtil.createSafeSheetName(deviceTrips.getDeviceName())); if (device.getGroupId() != 0) { Group group = Context.getDeviceManager().getGroupById(device.getGroupId()); if (group != null) { -- cgit v1.2.3