Quantcast
Channel: npoi Issue Tracker Rss Feed
Viewing all 690 articles
Browse latest View live

Created Unassigned: The supplied POIFSFileSystem does not contain a BIFF8 'Workbook' entry. Is it really an excel file? [13997]

$
0
0
I am using NPOI to process data in Excel 2003 (xls) file. This is my code

if (excelFormat.Equals(Constants.XLS_EXCEL_FORMAT))
{
using (FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
wbImportXLS = new HSSFWorkbook(file); //crash here
}
sheetImport = wbImportXLS.GetSheet(CommonController.GetFirstSheetNameInFileXLS(wbImportXLS));
isXLS = true;
}

However I receive an error

"The supplied POIFSFileSystem does not contain a BIFF8 'Workbook' entry. Is it really an excel file?"

I checked my excel file. That is not contain any password. I used Apache Tika and received this information

"Application-Name: Microsoft Excel
Author:
Category:
Comments:
Company:
Content-Length: 13312
Content-Type: application/vnd.ms-excel
Creation-Date: 2016-10-03T11:22:28Z
Keywords:
Last-Author:
Manager:
X-Parsed-By: org.apache.tika.parser.DefaultParser
X-Parsed-By: org.apache.tika.parser.microsoft.OfficeParser
X-TIKA:digest:MD5: f5a1e42d6d1674aadd0e03e8583cfbb3
X-TIKA:digest:SHA256: bffb673b20f3929d62e20514696d39406d524716f002dbec25284b64995ae9e0
comment:
cp:category:
cp:subject:
creator:
dc:creator:
dc:subject:
dc:title:
dcterms:created: 2016-10-03T11:22:28Z
extended-properties:Application: Microsoft Excel
extended-properties:Company:
extended-properties:Manager:
meta:author:
meta:creation-date: 2016-10-03T11:22:28Z
meta:keyword:
meta:last-author:
resourceName: TIKA.xls
subject:
title:
w:comments: "

However, if I open excel file and re-save, then my code work fine.

Commented Unassigned: Corrupted Excel files with NPOI - asp.net [12762]

$
0
0
Hi all, I need a small help with NPOI and asp.net.
I'm trying to create an excel file from a web application, written in asp.net (vb).
Everything is fine with excel 2003 xls format, while using the XSSF object model I get corrupted files.
Opening files in Excel I get the message that says file is corrupted, and can be restored (and actually Excel repairs it). The problem occurs even if I try to save stream into a file, rather than using memorystream.
Help is appreciated...
Here's the code, see attachment for error:

Dim wb As New XSSFWorkbook
Dim ws As new XSSFSheet
ws = wb.CreateSheet("Sheet1")
Dim r As XSSFRow
r = ws.CreateRow(0)
Dim c = r.CreateCell(0)
c.SetCellValue("Test")

Dim m As New IO.MemoryStream
m.Flush()
wb.Write(m)

Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Response.AddHeader("content-disposition", "attachment;filename=test.xlsx")
Response.Clear()
Response.BinaryWrite(m.GetBuffer())

Response.End()
Comments: ** Comment from web user: chantszhim **

I got the same problem after migrating the site from Windows Server 2008 R2 to Windows Server 2012 R2.

Commented Issue: XSSFWorkbook Write corrupts XLSX File [12847]

$
0
0
This may be a duplicate of [12616](https://npoi.codeplex.com/workitem/12616), but after much research, I haven't been able to track down a solution.

I compiled NPOI from source in Visual Studio 2013 with a direct pull from GitHub - the NPOI version is 2.0.8. The issue occurs with the NPOI NuGet package as well. I am opening the file with Excel 2010. Consider the following:

```
IWorkbook wb = null;
string file = "numbers.xlsx";

using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read)) {
if (Path.GetExtension(file).Contains("xlsx")) {
wb = new XSSFWorkbook(fs);
} else {
wb = new HSSFWorkbook(fs);
}
}

using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.ReadWrite)) {
wb.Write(fs);
}
```

This will render the output XLSX file unusable. [Case in point on Excel's reaction](http://imgur.com/AMglz1Y,bcCXi0d).

Workbooks created/written in-code with the XSSF API open correctly. XLS files opened/written with the HSSF API are fine with respect to Excel.

The FileMode/FileAccess/FileShare options for the FileStream do not seem to make a difference.

In practice I have been opening far more complex XLSX files, writing a few new cells to the rows therein, and writing back, where after the spreadsheet cannot be opened or subsequently recovered.

I've attached the aforementioned XLSX spreadsheet for testing purposes. Thanks for having a look.
Comments: ** Comment from web user: SachaK **

If the file stream is created with FileMode.Create instead of FileMode.Open it works fine. It's confusing because it works with both for xls files.

See http://stackoverflow.com/questions/36142337

Created Unassigned: NPOI.HSSF AutoFilter Issue: "File error: data may have been lost" [14011]

$
0
0
Getting "File error: data may have been lost" when opening saved Excel after setting auto-filter.
Example files attached.


Attempt to add data filter over all columns of Excel file using HSSFWorkbook

- NPOI Version 2.2.1
- XLS workbook generated by Crystal Reports export in an ASP.net webforms application
- Excel version: Excel 2016


Crystal Reports XLS Export - unmodified:
Code:

Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}.xls\"", reportTitle));

using (Stream reportStream = _reportDocument.ExportToStream(ExportFormatType.Excel))
{
reportStream.CopyTo(Response.OutputStream);
}

Response.Flush();
Response.Close();
Response.End();


Generated file "SimpleReport - unmodified.xls"
which opens in Excel without warning/error.


Crystal Reports XLS Export - auto-filter added with HSSFWorkbook:
Code:

HSSFWorkbook workbook;
using (Stream reportStream = _reportDocument.ExportToStream(ExportFormatType.Excel))
{
workbook = new HSSFWorkbook(reportStream);
}

workbook.Workbook.Records.Add(new CountryRecord() { DefaultCountry = 1, CurrentCountry = 1 }); // need this else NPOI throws an exception

ISheet sheet = workbook.GetSheetAt(0);
CellRangeAddress cellRange = new CellRangeAddress(sheet.FirstRowNum, sheet.LastRowNum, sheet.GetRow(sheet.FirstRowNum).FirstCellNum, sheet.GetRow(sheet.LastRowNum).LastCellNum - 1);
sheet.SetAutoFilter(cellRange);

Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}.xls\"", reportTitle));

workbook.Write(Response.OutputStream);

Response.Flush();
Response.Close();
Response.End();


Generated file "SimpleReport - filter set with HSSFWorkbook.xls".
When opening in Excel, a dialog is shown stating: "File error: data may have been lost".
The spreadsheet appears to be ok though.

Created Unassigned: NPOI.XSSF - SetAutoFilter results in missing/unreadable xml in XLSX [14012]

$
0
0
Getting warning: "We found a problem with some content in 'SimpleReport '. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes." when opening saved Excel after setting auto-filter.
Example files attached.

Attempt to add data filter over all columns of Excel file using XSSFWorkbook

- NPOI Version 2.2.1
- XLSX workbook generated by Crystal Reports export in an ASP.net webforms application
- Excel version: Excel 2016


Crystal Reports XLSX Export - unmodified:
Code:

Response.Clear();
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}.xlsx\"", reportTitle));

using (Stream exportStream = _reportDocument.ExportToStream(ExportFormatType.ExcelWorkbook))
{
exportStream.CopyTo(Response.OutputStream);
}

Response.Flush();
Response.Close();
Response.End();


Generated file "SimpleReport - unmodified export.xlsx"
which opens in Excel without warning/error.


Crystal Reports XLSX Export - auto-filter added with XSSFWorkbook:
Code:

XSSFWorkbook workbook;
using (Stream reportStream = _reportDocument.ExportToStream(ExportFormatType.ExcelWorkbook))
{
workbook = new XSSFWorkbook(reportStream);
}

if (!string.IsNullOrWhiteSpace(filterCellRange))
{
ISheet sheet = workbook.GetSheetAt(0);
CellRangeAddress cellRange = new CellRangeAddress(sheet.FirstRowNum, sheet.LastRowNum, sheet.GetRow(sheet.FirstRowNum).FirstCellNum, sheet.GetRow(sheet.LastRowNum).LastCellNum - 1);
sheet.SetAutoFilter(cellRange);
}


Response.Clear();
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}.xlsx\"", reportTitle));

workbook.Write(Response.OutputStream);

Response.Flush();
Response.Close();
Response.End();


Generated file "SimpleReport - filter added with XSSFWorkbook.xlsx".


When opening the .xlsx file, Excel shows a dialog stating "We found a problem with some content in 'SimpleReport '. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes."

If you click "Yes", you get a dialog stating that "Excel was able to open the file by repairing or removing the unreadable content." and detail as follows: "Removed Part: /xl/styles.xml part with XML error. (Styles) Load error. Line 1, column 0.
Repaired Records: Cell information from /xl/worksheets/Sheet1.xml part".

It also points you to a log file with the contents:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>error223040_01.xml</logFileName><summary>Errors were detected in file 'D:\work\AgeUK\AREP-66 - AgeUK MI (Management Information) Suite\TEST\SimpleReport Export\XLSX Export\SimpleReport - filter added with XSSFWorkbook - Copy.xlsx'</summary><removedParts><removedPart>Removed Part: /xl/styles.xml part with XML error. (Styles) Load error. Line 1, column 0.</removedPart></removedParts><repairedRecords><repairedRecord>Repaired Records: Cell information from /xl/worksheets/Sheet1.xml part</repairedRecord></repairedRecords></recoveryLog>

Created Unassigned: Table1[Data1] can be resolved? [14014]

$
0
0
Hi.

Sheet sample:
```
|Data1|Data2|Data3|
|-----|-----|-----|
| 1| 2| 3|
| 4| 5| 6|
| 7| 8| 9|
```

Name Data1 is represented as __Table1[Data1]__. I can get actual cell range __=Sheet1!$A$2:$A$4__ if I delete and convert the table to ranges.


C# problem code:
```
XSSFWorkbook workbook = new XSSFWorkbook(fs);
var name = workbook.GetName("Data1");
var cells = new AreaReference(name.RefersToFormula);
```

AreaReference throws FormatException.

Another approach? I have tried ILSpy. Here is another one:
```
XSSFWorkbook workbook = new XSSFWorkbook(fs);
XSSFEvaluationWorkbook ev = XSSFEvaluationWorkbook.Create(workbook);
var name = workbook.GetName("Data1");
var ptgs = FormulaParser.Parse(name.RefersToFormula, ev);
```

Result:
* FormulaParseException: Specified named range 'Table1' does not exist in the current workbook.

Any good workaround?

Created Unassigned: FillForegroundColor is slow [14016]

$
0
0
I have a template and after filling it with values I set a background color but for a small file (about 6000 rows) it takes about 4 minutes. Whithout setting background color it takes only 8 seconds.

My code is:
var hssfworkbook = new XSSFWorkbook(file);
var sheet = hssfworkbook.GetSheetAt(0);

for (int i=0; i<sheet.LastRowNum; i++)
{
var currentCellStyle = hssfworkbook.CreateCellStyle();
currentCellStyle.FillForegroundColor = IndexedColors.Green.Index;
currentRow.Cells.ForEach(x=> x.CellStyle = currentCellStyle);
}

Created Unassigned: DataValidation Explicit Values Extra Quotes [14021]

$
0
0
When setting data validation to an explicit list in excel, say 1 and 2, NPOI reads the datavalidation formula enclosed in an extra double quotes: ""1,2"" instead of "1,2", resulting in the ExplicitValues array to also contains the quotes.

using NPOI 2.2.1

Nic

Commented Unassigned: NPOI.XSSF - SetAutoFilter results in missing/unreadable xml in XLSX [14012]

$
0
0
Getting warning: "We found a problem with some content in 'SimpleReport '. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes." when opening saved Excel after setting auto-filter.
Example files attached.

Attempt to add data filter over all columns of Excel file using XSSFWorkbook

- NPOI Version 2.2.1
- XLSX workbook generated by Crystal Reports export in an ASP.net webforms application
- Excel version: Excel 2016


Crystal Reports XLSX Export - unmodified:
Code:

Response.Clear();
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}.xlsx\"", reportTitle));

using (Stream exportStream = _reportDocument.ExportToStream(ExportFormatType.ExcelWorkbook))
{
exportStream.CopyTo(Response.OutputStream);
}

Response.Flush();
Response.Close();
Response.End();


Generated file "SimpleReport - unmodified export.xlsx"
which opens in Excel without warning/error.


Crystal Reports XLSX Export - auto-filter added with XSSFWorkbook:
Code:

XSSFWorkbook workbook;
using (Stream reportStream = _reportDocument.ExportToStream(ExportFormatType.ExcelWorkbook))
{
workbook = new XSSFWorkbook(reportStream);
}

if (!string.IsNullOrWhiteSpace(filterCellRange))
{
ISheet sheet = workbook.GetSheetAt(0);
CellRangeAddress cellRange = new CellRangeAddress(sheet.FirstRowNum, sheet.LastRowNum, sheet.GetRow(sheet.FirstRowNum).FirstCellNum, sheet.GetRow(sheet.LastRowNum).LastCellNum - 1);
sheet.SetAutoFilter(cellRange);
}


Response.Clear();
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}.xlsx\"", reportTitle));

workbook.Write(Response.OutputStream);

Response.Flush();
Response.Close();
Response.End();


Generated file "SimpleReport - filter added with XSSFWorkbook.xlsx".


When opening the .xlsx file, Excel shows a dialog stating "We found a problem with some content in 'SimpleReport '. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes."

If you click "Yes", you get a dialog stating that "Excel was able to open the file by repairing or removing the unreadable content." and detail as follows: "Removed Part: /xl/styles.xml part with XML error. (Styles) Load error. Line 1, column 0.
Repaired Records: Cell information from /xl/worksheets/Sheet1.xml part".

It also points you to a log file with the contents:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>error223040_01.xml</logFileName><summary>Errors were detected in file 'D:\work\AgeUK\AREP-66 - AgeUK MI (Management Information) Suite\TEST\SimpleReport Export\XLSX Export\SimpleReport - filter added with XSSFWorkbook - Copy.xlsx'</summary><removedParts><removedPart>Removed Part: /xl/styles.xml part with XML error. (Styles) Load error. Line 1, column 0.</removedPart></removedParts><repairedRecords><repairedRecord>Repaired Records: Cell information from /xl/worksheets/Sheet1.xml part</repairedRecord></repairedRecords></recoveryLog>
Comments: ** Comment from web user: Zebrette **

same issue for me, already reported under Id #13957. I suggest merging the bugs

Commented Unassigned: NPOI.HSSF AutoFilter Issue: "File error: data may have been lost" [14011]

$
0
0
Getting "File error: data may have been lost" when opening saved Excel after setting auto-filter.
Example files attached.


Attempt to add data filter over all columns of Excel file using HSSFWorkbook

- NPOI Version 2.2.1
- XLS workbook generated by Crystal Reports export in an ASP.net webforms application
- Excel version: Excel 2016


Crystal Reports XLS Export - unmodified:
Code:

Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}.xls\"", reportTitle));

using (Stream reportStream = _reportDocument.ExportToStream(ExportFormatType.Excel))
{
reportStream.CopyTo(Response.OutputStream);
}

Response.Flush();
Response.Close();
Response.End();


Generated file "SimpleReport - unmodified.xls"
which opens in Excel without warning/error.


Crystal Reports XLS Export - auto-filter added with HSSFWorkbook:
Code:

HSSFWorkbook workbook;
using (Stream reportStream = _reportDocument.ExportToStream(ExportFormatType.Excel))
{
workbook = new HSSFWorkbook(reportStream);
}

workbook.Workbook.Records.Add(new CountryRecord() { DefaultCountry = 1, CurrentCountry = 1 }); // need this else NPOI throws an exception

ISheet sheet = workbook.GetSheetAt(0);
CellRangeAddress cellRange = new CellRangeAddress(sheet.FirstRowNum, sheet.LastRowNum, sheet.GetRow(sheet.FirstRowNum).FirstCellNum, sheet.GetRow(sheet.LastRowNum).LastCellNum - 1);
sheet.SetAutoFilter(cellRange);

Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}.xls\"", reportTitle));

workbook.Write(Response.OutputStream);

Response.Flush();
Response.Close();
Response.End();


Generated file "SimpleReport - filter set with HSSFWorkbook.xls".
When opening in Excel, a dialog is shown stating: "File error: data may have been lost".
The spreadsheet appears to be ok though.
Comments: ** Comment from web user: Zebrette **

same issue for me, already reported under Id #13957 (and #14012?). I suggest merging the bugs

Created Unassigned: Append a cell / raw to saved/existing xls file [14025]

$
0
0
Hi Team /All.

I'm new to NPOI, I had started today and I must say well done !.
I have the following issue and I hope you can help / explain it to me.

I would like to write 10 different cells to a xls file, But i must save the file after each modification.
I tried to use the ".Write(file)" method and I get a big file but with results of only the first save. (all other 9 changes are not saved).

I tried to search for this issue but I could not find an answer.

Thanks in advance,
Eyal.

Created Unassigned: Shape of the comment box to a giant Curved Arrow [14045]

$
0
0
As mentioned in some java posts, comment boxes are changing shape by themselves when saving XLSX.
Here is one bugzilla link:
https://bz.apache.org/bugzilla/show_bug.cgi?id=55410
And MS link:
https://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_windows8/comment-boxes-changing-shape-by-themselves/db78c2e1-756a-48f9-ba30-ab062993a0ab

So, are there any fixes already for NPOI in C# for this problem?

Thanks in advance
David

Created Unassigned: Excel Error-In the Excel File multiple Sheet with pivot Table ,Excel Write Issue [14062]

$
0
0
Hi All team / I have the following issue and I hope you can help / explain it to me.
I Have one template of excel file ,in this excel file 1st sheet is pivot table and 2nd normal data sheet ,but right now problem is donot wite this file some exception through NPOI ( using XSSFWorkbook) .
Exception Is -( The method or operation is not implemented.) I try to solved this issue but i could not solved.
So please give me better solution on this issue.

Commented Unassigned: Shape of the comment box changes to a giant Curved Arrow [14045]

$
0
0
As mentioned in some java posts, comment boxes are changing shape by themselves when saving XLSX.
Here is one bugzilla link:
https://bz.apache.org/bugzilla/show_bug.cgi?id=55410
And MS link:
https://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_windows8/comment-boxes-changing-shape-by-themselves/db78c2e1-756a-48f9-ba30-ab062993a0ab

So, are there any fixes already for NPOI in C# for this problem?

Thanks in advance
David
Comments: ** Comment from web user: Davideloper **


One hack solution is here:
https://npoi.codeplex.com/workitem/13958

It works for me!

Created Unassigned: Npoi Round Formula [14073]

$
0
0
Hi, I' have this round problem: the number 37803.49142 was being used in the Excel ROUND() function to 0dp. e.g. ROUND(37803.49142, 0)

When executing this using the same workbook:

Excel would evaluate to 37803
NPOI would evaluate to 37804

Any suggestion? Is it a NPOI bug?

Thanks in advance.

Diego Parolin.

Created Unassigned: DOCX Header Picture [14077]

$
0
0
Hi,

I recently updated my version to 2.2.1 and in this version picture i put in the Header corrupts the document.

The same code worked without a problem until this version.

Created Unassigned: Opening and saving existing XLSM spreadsheet detaches macros from controls [14081]

$
0
0
I have an XLSM spreadsheet which contains form controls with macros attached.
Opening this spreadsheet with NPOI and then saving it causes all macros to be detached from controls.
I have to manually assign macros to all controls.

Created Unassigned: Could not install package [14097]

$
0
0
Could not install package 'NPOI 2.3.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile78', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Commented Unassigned: Could not install package [14097]

$
0
0
Could not install package 'NPOI 2.3.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile78', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
Comments: ** Comment from web user: amalroshand **

Any help please. i want to use this in a xamarin cross platform mobile app.
Or any suggestions are welcome...

Created Unassigned: Document with links corrupted [14102]

$
0
0
MSO write that document corrupted and remove hyperlinks from /xl/worksheets/sheet1.xml
LibreOffice 5.2.5.1 open document fine and links work but after resaving links missed too.
Document sample attached

NPOI 2.2.1
Viewing all 690 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>