Issue 351 - truncate exports to Excel at 256 columns (limitation of Excel format)
git-svn-id: http://google-refine.googlecode.com/svn/trunk@2094 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
6a14049652
commit
51c898d602
@ -75,8 +75,12 @@ public class XlsExporter implements StreamExporter {
|
|||||||
|
|
||||||
int cellCount = 0;
|
int cellCount = 0;
|
||||||
for (Column column : project.columnModel.columns) {
|
for (Column column : project.columnModel.columns) {
|
||||||
org.apache.poi.ss.usermodel.Cell c = r.createCell(cellCount++);
|
if (cellCount++ > 255) {
|
||||||
c.setCellValue(column.getName());
|
// TODO: Warn user about truncated data
|
||||||
|
} else {
|
||||||
|
org.apache.poi.ss.usermodel.Cell c = r.createCell(cellCount);
|
||||||
|
c.setCellValue(column.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,43 +105,48 @@ public class XlsExporter implements StreamExporter {
|
|||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean visit(Project project, int rowIndex, Row row) {
|
public boolean visit(Project project, int rowIndex, Row row) {
|
||||||
org.apache.poi.ss.usermodel.Row r = sheet.createRow(rowCount++);
|
org.apache.poi.ss.usermodel.Row r = sheet.createRow(rowCount++);
|
||||||
|
|
||||||
int cellCount = 0;
|
int cellCount = 0;
|
||||||
for (Column column : project.columnModel.columns) {
|
for (Column column : project.columnModel.columns) {
|
||||||
org.apache.poi.ss.usermodel.Cell c = r.createCell(cellCount++);
|
if (cellCount++ > 255) {
|
||||||
|
// TODO: Warn user about truncated data
|
||||||
|
} else {
|
||||||
|
org.apache.poi.ss.usermodel.Cell c = r.createCell(cellCount);
|
||||||
|
|
||||||
int cellIndex = column.getCellIndex();
|
int cellIndex = column.getCellIndex();
|
||||||
if (cellIndex < row.cells.size()) {
|
if (cellIndex < row.cells.size()) {
|
||||||
Cell cell = row.cells.get(cellIndex);
|
Cell cell = row.cells.get(cellIndex);
|
||||||
if (cell != null) {
|
if (cell != null) {
|
||||||
if (cell.recon != null && cell.recon.match != null) {
|
if (cell.recon != null && cell.recon.match != null) {
|
||||||
c.setCellValue(cell.recon.match.name);
|
c.setCellValue(cell.recon.match.name);
|
||||||
|
|
||||||
HSSFHyperlink hl = new HSSFHyperlink(HSSFHyperlink.LINK_URL);
|
HSSFHyperlink hl = new HSSFHyperlink(HSSFHyperlink.LINK_URL);
|
||||||
hl.setLabel(cell.recon.match.name);
|
hl.setLabel(cell.recon.match.name);
|
||||||
hl.setAddress("http://www.freebase.com/view" + cell.recon.match.id);
|
hl.setAddress("http://www.freebase.com/view" + cell.recon.match.id);
|
||||||
|
|
||||||
c.setHyperlink(hl);
|
c.setHyperlink(hl);
|
||||||
} else if (cell.value != null) {
|
} else if (cell.value != null) {
|
||||||
Object v = cell.value;
|
Object v = cell.value;
|
||||||
|
|
||||||
if (v instanceof Number) {
|
if (v instanceof Number) {
|
||||||
c.setCellValue(((Number) v).doubleValue());
|
c.setCellValue(((Number) v).doubleValue());
|
||||||
} else if (v instanceof Boolean) {
|
} else if (v instanceof Boolean) {
|
||||||
c.setCellValue(((Boolean) v).booleanValue());
|
c.setCellValue(((Boolean) v).booleanValue());
|
||||||
} else if (v instanceof Date) {
|
} else if (v instanceof Date) {
|
||||||
c.setCellValue((Date) v);
|
c.setCellValue((Date) v);
|
||||||
} else if (v instanceof Calendar) {
|
} else if (v instanceof Calendar) {
|
||||||
c.setCellValue((Calendar) v);
|
c.setCellValue((Calendar) v);
|
||||||
} else if (v instanceof String) {
|
} else if (v instanceof String) {
|
||||||
String s = (String) v;
|
String s = (String) v;
|
||||||
if (s.length() > 32767) {
|
if (s.length() > 32767) {
|
||||||
// The maximum length of cell contents (text) is 32,767 characters
|
// The maximum length of cell contents (text) is 32,767 characters
|
||||||
s = s.substring(0, 32767);
|
s = s.substring(0, 32767);
|
||||||
|
}
|
||||||
|
c.setCellValue(s);
|
||||||
}
|
}
|
||||||
c.setCellValue(s);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user