You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2004/11/15 22:35:25 UTC
DO NOT REPLY [Bug 32256] New: -
Output .xls file unreadable when link label >= 128 characters
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32256>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=32256
Summary: Output .xls file unreadable when link label >= 128
characters
Product: POI
Version: 2.5
Platform: All
OS/Version: Mac OS X 10.0
Status: NEW
Severity: normal
Priority: P2
Component: HSSF
AssignedTo: poi-dev@jakarta.apache.org
ReportedBy: jesse@swank.ca
I am using poi-2.5.1-final-20040804.jar with Microsoft Office 2004 for Mac. I have used POI to create a
.xls file that is unreadable by Microsoft Excel.
When I attempt to open the file created by POI, Excel reports a dialog, "Unable to read file." when I
attempt to open it. The file is unreadable only when a hyperlink label is >= 128 characters. The exact
same document opens fine if the hyperlink label is 127 characters or less.
See also issue 32255. In this case, POI writes the XLS file correctly without an
ArrayIndexOutOfBoundsException. The difference between the issues is that this hyperlink points to a
different sheet.
Here is a test program. Execute it with a 128 (or greater) character parameter to create a broken Excel
file:
import java.util.*;
import java.io.*;
import org.apache.poi.hssf.usermodel.*;
/**
* This class uses POI to create an XLS file which cannot be read by
* Microsoft Excel.
*
* @author <a href="mailto:jesse@swank.ca">Jesse Wilson</a>
*/
public class ExcelHyperlink2 {
public static void main(String[] args) throws IOException {
if(args.length != 1) {
System.out.println("Usage: ExcelHyperlink label");
return;
}
// the target sheet
String targetSheetName = "2";
// create a workbook, sheet, row and cell
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet1 = workbook.createSheet("1");
HSSFRow row = sheet1.createRow((short)0);
HSSFCell cell = row.createCell((short)0);
// create a hyperlink in our cell, labelled by the argument
String target = "\"#" + targetSheetName + "!B2\"";
String label = "\"" + args[0] + "\"";
String formula = "HYPERLINK(" + target + ", " + label + ")";
System.out.println(formula);
cell.setCellFormula(formula);
// create a target sheet
HSSFSheet sheet2 = workbook.createSheet(targetSheetName);
// write the file
FileOutputStream xlsOut = new FileOutputStream(new File("hyperlink.xls"));
workbook.write(xlsOut);
xlsOut.close();
}
}
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-dev-help@jakarta.apache.org