Quantcast
Channel: NPOI
Viewing all 1621 articles
Browse latest View live

Commented Unassigned: Problem with XLSX (XSSF) [13046]

$
0
0
Hi all,
I'm an Italian user of NPOI (with bad written English) ;)

I have a problem with xlsx generation. When I open the spreadsheet created with NPOI, Excel return me this message:
"Excel found an unreadable content"
but it opens correctly the file.
I have tried to download and re-compile sources from (github - https://github.com/tonyqus/npoi) with the same issue.
---------
I also have a problem with "AutoSizeColumn" in XSSF workbook ... this function not work properly.

Thanks,
Valerio
Comments: ** Comment from web user: prashantedspl **

I am also facing the same issue with my file.
please let me know where is the problem!!


Commented Unassigned: Problem with XLSX (XSSF) [13046]

$
0
0
Hi all,
I'm an Italian user of NPOI (with bad written English) ;)

I have a problem with xlsx generation. When I open the spreadsheet created with NPOI, Excel return me this message:
"Excel found an unreadable content"
but it opens correctly the file.
I have tried to download and re-compile sources from (github - https://github.com/tonyqus/npoi) with the same issue.
---------
I also have a problem with "AutoSizeColumn" in XSSF workbook ... this function not work properly.

Thanks,
Valerio
Comments: ** Comment from web user: prashantedspl **

my file name is CodeProvisionTemplate (5).xlsx

Created Unassigned: Issue in newly generated xlsx file using XSSF [13934]

$
0
0
Hello,

I had created a .xlsx file using XSSF of NPOI.
when I am opening the .xlsx file, I got the attached screens first and then excel file opens.

can someone please help me on this issue ?

New Post: Excel Conversion to PDF using NPOI

$
0
0
@tonyqus you just killed my dreams :'(

Updated Wiki: Home

$
0
0
.NET技术 QQ联盟群:
上海 343027179 (已转实践营)
北京 124527967
深圳 297128022
广州 550850466
西安 136569834
武汉 52997745
成都 136569750
天津 541104478
(周边城市请就近添加,谢谢)
 
Who are We
Neuzilla is the studio behind NPOI. For detail, you can check http://blog.neuzilla.com/.

 

 
What's NPOI
This project is the .NET version of POI Java project at http://poi.apache.org/. POI is an open source project which can help you read/write xls, doc, ppt files. It has a wide application.
 
For example, you can use it to
a. generate a Excel report without Microsoft Office suite installed on your server and more efficient than call Microsoft Excel ActiveX at background;
b. extract text from Office documents to help you implement full-text indexing feature (most of time this feature is used to create search engines).
c. extract images from Office documents
d. generate Excel sheets that contains formulas
 
Our Sponsor (赞助商)
 
E-iceblue is a community sponsor of NPOI. 提供中文技术支持
Don't forget to have a try on Free Spire.XLS
XLS
 
 
Donate NPOI

支付宝捐款账号: tonyqus@163.com
Paypal: tonyqus@gmail.com


donate_btn
 
 
Advantage of NPOI
a. It's totally free to use
b. Cover most features of Excel (cell style, data format, formula and so on)
c. Support xls, xlsx, docx.
d. Designed to be interface-oriented (take a look at NPOI.SS namespace)
e. Support not only export but also import
f. .Net 2.0 based even for xlsx and docx (though we also support .NET 4.0)
g. Successful cases from all over the world
h. huge amout of basic examples
i. No dependency on isolated storage
 
To get the latest code, please visithttps://github.com/tonyqus/npoi.
 
 
Comments from NPOI users
image
image
image
image
image
 
 
Tutorial

NPOI on SNS
中文
QQ群: 189925337
 
English

System Requirement
VS2010 with .NET 4.0 runtime
VS2005 or VS2008 with .NET 2.0 Runtime (SP1)
vs2003 with .NET 1.1
Mono
medium trust environment in ASP.NET

 

 

 
Extensions
 

Released: NPOI 2.2.1 (May 21, 2016)

$
0
0
.NET技术 QQ联盟群:
上海 343027179 (已转实践营)
北京 124527967
深圳 297128022
广州 550850466
西安 136569834
武汉 52997745
成都 136569750
天津 541104478
(周边城市请就近添加,谢谢)

If you feel the release is good, buy me a coffee by donating to Paypal acount tonyqus@gmail.com. Thank you!

Follow us on Linkedin to get latest updates about NPOI: http://www.linkedin.com/company/neuzilla

Bug Fixes
- Fix a lot of serialization issue of ooxml issue
- Fix phonetic guides tag reading/writing issue
- Fix XWPFRun SetText exception issue
- Fix xml security issue
- Optimize memory for AutoResizeColumn
- Fix sqref property is missing on ProtectedRange
- Fix drawing ooxml issue and cell value bug
- Fix numFmtId property issue on NumFmt node
- Fix ooxml issues for RadarChart and CellStyle
- Fix xfrm namespace issue in ooxml
- Fix ScatterChart issue in ooxml
- Fix ooxml bugs in Vml entities
- fix bug when call ISheet.RemoveRow, it removes a wrong row
- don't close zip stream when zipoutputstream finish writing

Updated Release: NPOI 2.2.1 (5月 21, 2016)

$
0
0
.NET技术 QQ联盟群:
上海 343027179 (已转实践营)
北京 124527967
深圳 297128022
广州 550850466
西安 136569834
武汉 52997745
成都 136569750
天津 541104478
(周边城市请就近添加,谢谢)

If you feel the release is good, buy me a coffee by donating to Paypal acount tonyqus@gmail.com. Thank you!

Follow us on Linkedin to get latest updates about NPOI: http://www.linkedin.com/company/neuzilla

Bug Fixes
- Fix a lot of serialization issue of ooxml issue
- Fix phonetic guides tag reading/writing issue
- Fix XWPFRun SetText exception issue
- Fix xml security issue
- Optimize memory for AutoResizeColumn
- Fix sqref property is missing on ProtectedRange
- Fix drawing ooxml issue and cell value bug
- Fix numFmtId property issue on NumFmt node
- Fix ooxml issues for RadarChart and CellStyle
- Fix xfrm namespace issue in ooxml
- Fix ScatterChart issue in ooxml
- Fix ooxml bugs in Vml entities
- fix bug when call ISheet.RemoveRow, it removes a wrong row
- don't close zip stream when zipoutputstream finish writing

Commented Unassigned: Issue in newly generated xlsx file using XSSF [13934]

$
0
0
Hello,

I had created a .xlsx file using XSSF of NPOI.
when I am opening the .xlsx file, I got the attached screens first and then excel file opens.

can someone please help me on this issue ?
Comments: ** Comment from web user: prashantedspl **

Hello Tony,

Hope you checked and understood the issue of mine..

please provide me the solution or update the package asap.

Thank you.


New Post: Read/Write XLSM using POI

$
0
0
Hi guys,

I'm using POI in my c# code for few weeks, and i've found and issue i don't manage to solve: Xlsm
I've to open an xlsm template, edit it and save it. The template contains Macro, but i just add data into the xlsm file.
Actually, I think that read and Edit work find (thanks to debugging in vs), the issue is when I try to write...
The code is working, there is no error, but when I Try to open it with Excel, it crashes..
for example, even this crashes..

FileStream temp = new FileStream(xlsm_file, FileMode.Open, FileAccess.ReadWrite);
XSSFWorkbook workbook = (XSSFWorkbook)WorkbookFactory.Create(temp);
XSSFSheet sheet = (XSSFSheet)workbook.GetSheetAt(0);
workbook.SetSheetName(0, sheetname.Substring(0, Math.Min(sheetname.Length, 30)));
IRow header_Row = sheet.GetRow(0);
temp.Close();
FileStream toWrite = new FileStream(xlsm_file, FileMode.Open, FileAccess.ReadWrite);
workbook.Write(toWrite);
toWrite.Close();

Is anyone having an Idea?
Thanks !

New Post: Excel Conversion to PDF using NPOI

$
0
0
iTextSharp is great for doing that

Created Unassigned: System.InvalidOperationException when calling XSSFSheet.GetColumnStyle for column with General style [13950]

$
0
0
Trying to get style of default (General) column throws InvalidOperationException. I've traced the problem to NPOI.XSSF.UserModel.Helpers.ColumnHelper.GetColDefaultStyle method when column style property of CT_Col.style is cast to int. This property is declared as nullable uint (uint?), so the code is missing HasValue call before accessing Nullable Value.

``` C#
// NPOI.XSSF.UserModel.Helpers.ColumnHelper
public int GetColDefaultStyle(long index)
{
if (this.GetColumn(index, false) != null)
{
return (int)this.GetColumn(index, false).style;
}
return -1;
}
```

Updated Wiki: Home

$
0
0
Who are We
Neuzilla is the studio behind NPOI. For detail, you can check http://blog.neuzilla.com/.

 

 
What's NPOI
This project is the .NET version of POI Java project at http://poi.apache.org/. POI is an open source project which can help you read/write xls, doc, ppt files. It has a wide application.
 
For example, you can use it to
a. generate a Excel report without Microsoft Office suite installed on your server and more efficient than call Microsoft Excel ActiveX at background;
b. extract text from Office documents to help you implement full-text indexing feature (most of time this feature is used to create search engines).
c. extract images from Office documents
d. generate Excel sheets that contains formulas
 
Our Sponsor (赞助商)
 
E-iceblue is a community sponsor of NPOI. 提供中文技术支持
Don't forget to have a try on Free Spire.XLS
XLS
 
 
Donate NPOI

支付宝捐款账号: tonyqus@163.com
Paypal: tonyqus@gmail.com


donate_btn
 
 
Advantage of NPOI
a. It's totally free to use
b. Cover most features of Excel (cell style, data format, formula and so on)
c. Support xls, xlsx, docx.
d. Designed to be interface-oriented (take a look at NPOI.SS namespace)
e. Support not only export but also import
f. .Net 2.0 based even for xlsx and docx (though we also support .NET 4.0)
g. Successful cases from all over the world
h. huge amout of basic examples
i. No dependency on isolated storage
 
To get the latest code, please visithttps://github.com/tonyqus/npoi.
 
 
Comments from NPOI users
image
image
image
image
image
 
 
Tutorial

NPOI on SNS
中文
QQ群: 189925337
 
English

System Requirement
VS2010 with .NET 4.0 runtime
VS2005 or VS2008 with .NET 2.0 Runtime (SP1)
vs2003 with .NET 1.1
Mono
medium trust environment in ASP.NET

 

 

 
Extensions
 

Created Unassigned: Writing xlsx workbook with active filtering gives corrupted file [13957]

$
0
0
If you open a xlsx workbook that has active filter (filtering turned on AND filter applied such as having rows filtered out), writing it to the disk will create a corrupted file:

"We found a problem with some content in 'filename'. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes."

Then click Yes

"Repaired part: /xl/worksheets/sheet1.xml part with XMl error. Load error. Line 1, column 693."

original xlsx file and corrupted one attached, method to obtain corrupted file below

```
Sub Main()

Dim wb As IWorkbook = WorkbookFactory.Create(originalfilepath)
Using writeStream As New FileStream(newfilepath, FileMode.Create, FileAccess.Write)
wb.Write(writeStream)
End Using

End Sub
```

Created Unassigned: Adding XSSFComment causes corrupted comments due to unnecessary elements in CT_ShapeType [13958]

$
0
0
When adding a new XSSFComment using the following code

```
IDrawing patr = sheet.CreateDrawingPatriarch();

var anchor = NPOIHelper.CreateAnchor(sheet.Workbook, 0, 0, 0, 0, 0, 0, 4, 4);

anchor.AnchorType = AnchorType.DontMoveAndResize;
IComment comment = patr.CreateCellComment(anchor);
comment.String = new XSSFRichTextString(commentVal);
comment.Author = "";

NPOIHelper.FormatComment(sheet, comment);


row.GetCell(colIndex, MissingCellPolicy.CREATE_NULL_AS_BLANK).CellComment = comment;

```

Two things happen.

1. On all versions of excel, if you open excel and save the document then reopen, the comment turns into a arrow as it seems to become a two cell anchored comment.
2. On versions of excel <= 2010, the background of the cell is blank

This appears to be because of two extra elements in the v:shapetype element in the VML diagram. If stroked="f" filled="f" are present these issues occur. If they are not there, everything works fine. There's no way I can tell in the API to remove these, but I think by default they should be omitted from the VML.

I've implemented a hack to work around it using reflection

```
BindingFlags bindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;

XSSFSheet xssfSheet = (XSSFSheet)sheet;

MethodInfo methodInfo = xssfSheet.GetType().GetMethod("GetVMLDrawing", bindFlags);
XSSFVMLDrawing vmlDrawing = (XSSFVMLDrawing)methodInfo.Invoke(xssfSheet, new object[] { false });

MethodInfo methodInfo2 = vmlDrawing.GetType().GetMethod("GetItems", bindFlags);
ArrayList arrayList = (ArrayList)methodInfo2.Invoke(vmlDrawing, new object[] { });

foreach (var obj in arrayList)
{
if (obj is CT_Shapetype)
{
var shapeType = (CT_Shapetype)obj;
shapeType.filled = ST_TrueFalse.@true;
shapeType.stroked = ST_TrueFalse.@true;
}
}

```
Very dirty but it resolves the problem.

Thanks!

New Post: SetFillColor function is not present in HSSFComment.

$
0
0
Hello ,

I am trying to export XLSX file with Comments . I was able to achieve the same with XSSFWorkbook but I was unable to set Background Color for the Comment Bubble. When I checked HSSFWorkbook where in HSSFComment the SetFillColor function is able to set the background color but I was unable to find the same in XSSF .

I implemented based on the below example but I didnt find the SetFillColor function in XSSF .
XSSF

Please help to add background to COMMENT in XLSX file.

Thanks,
bk

Created Unassigned: comments have random background shapes [13962]

$
0
0
in XSSF (Microsoft Office Excel xlsx files in office 2007) I can add comments to documents. However, the comments get random background style shapes, like arrows, balloons, sqaure box etc.

Created Unassigned: Rgb values are wrong [13965]

$
0
0
With XSSF, if I try to copy the CellStyle of a cell of a second sheet of a .xlxs file, the copied values are not correct: FillForegroundColor, FillForegroundColorColor and FillForegroundXSSFColor have the wrong rgb values (become 255 instead of 192), it is wrong the value of the color that is 0 instead of 22 also.
If I convert the files in xls and I read with HSSF the same cells by the same method, the values are correct.
I enclose two pictures with the values that come back to me and I copy part of the code.
I tried with 2.2.1 and 2.1.3.1 versions.

```
XSSFWorkbook wb;
XSSFSheet sh;
XSSFSheet shStyle;

using (var fs = new FileStream("style.xlsx", FileMode.Open, FileAccess.Read))
{
wb = new XSSFWorkbook(fs);
}

sh = (XSSFSheet)wb.GetSheet(wb.GetSheetAt(0).SheetName);
shStyle = (XSSFSheet)wb.GetSheet(wb.GetSheetAt(1).SheetName);

HSSFWorkbook wbo;
HSSFSheet sho;
HSSFSheet shStyleo;

using (var fso = new FileStream("style.xls", FileMode.Open, FileAccess.Read))
{
wbo = new HSSFWorkbook(fso);
}

sho = (HSSFSheet)wbo.GetSheet(wbo.GetSheetAt(0).SheetName);
shStyleo = (HSSFSheet)wbo.GetSheet(wbo.GetSheetAt(1).SheetName);

ICellStyle StyleXlsx = shStyle.GetRow(2).GetCell(0).CellStyle;
ICellStyle StyleXls = shStyleo.GetRow(2).GetCell(0).CellStyle;

```

New Post: NPOI Open Xlsx document modified on Apple system

$
0
0
Hi everyone,

i've a problem when i try to open a workbook with XSSFWorkbook method.
With a lot of xlsx file i've got no problem, but if we made some changes on a excel file with a Mac Pro and try to open it in my project i got this error stacktrace :
Wrong Local header signature: 0x4ACF92AD
ICSharpCode.SharpZipLib
à ICSharpCode.SharpZipLib.Zip.ZipInputStream.GetNextEntry()
   à NPOI.OpenXml4Net.Util.ZipInputStreamZipEntrySource..ctor(ZipInputStream inp)
   à NPOI.OpenXml4Net.OPC.ZipPackage..ctor(Stream filestream, PackageAccess access)
   à NPOI.OpenXml4Net.OPC.OPCPackage.Open(Stream in1)
   à NPOI.Util.PackageHelper.Open(Stream is1)
   à NPOI.XSSF.UserModel.XSSFWorkbook..ctor(Stream is1)
You can found code i wrote below :
        protected static IWorkbook GetWorkbook(FileInfo file)
        {
            IWorkbook workBook = null;

            using (var stream = file.OpenRead())
            {
                stream.Position = 0; // <-------- rewind the stream
                if (file.Name.ToUpper().EndsWith(".XLSX"))
                    workBook = new XSSFWorkbook(stream);
                else if (file.Name.ToUpper().EndsWith(".XLS"))
                    workBook = new HSSFWorkbook(stream);
            }

            return workBook;
        }
I think i've a problem when we save it on Appel and try to read it on Microsoft system.

How can i do to solve it and allow my project to open Excel file by any possible mean ?

Thanks a lot

Created Unassigned: NPOI Open Xlsx document modified on Apple system [13967]

$
0
0
Hi everyone,

i've a problem when i try to open a workbook with XSSFWorkbook method.
With a lot of xlsx file i've got no problem, but if we made some changes on a excel file with a Mac Pro and try to open it in my project i got this error stacktrace :

```
Wrong Local header signature: 0x4ACF92AD
ICSharpCode.SharpZipLib
```

```
à ICSharpCode.SharpZipLib.Zip.ZipInputStream.GetNextEntry()
à NPOI.OpenXml4Net.Util.ZipInputStreamZipEntrySource..ctor(ZipInputStream inp)
à NPOI.OpenXml4Net.OPC.ZipPackage..ctor(Stream filestream, PackageAccess access)
à NPOI.OpenXml4Net.OPC.OPCPackage.Open(Stream in1)
à NPOI.Util.PackageHelper.Open(Stream is1)
à NPOI.XSSF.UserModel.XSSFWorkbook..ctor(Stream is1)
```

You can found code i wrote below :

```
protected static IWorkbook GetWorkbook(FileInfo file)
{
IWorkbook workBook = null;

using (var stream = file.OpenRead())
{
stream.Position = 0; // <-------- rewind the stream
if (file.Name.ToUpper().EndsWith(".XLSX"))
workBook = new XSSFWorkbook(stream);
else if (file.Name.ToUpper().EndsWith(".XLS"))
workBook = new HSSFWorkbook(stream);
}

return workBook;
}
```

I think i've a problem when we save it on Appel and try to read it on Microsoft system.

How can i do to solve it and allow my project to open Excel file by any possible mean ?

Thanks a lot

Commented Unassigned: NPOI Open Xlsx document modified on Apple system [13967]

$
0
0
Hi everyone,

i've a problem when i try to open a workbook with XSSFWorkbook method.
With a lot of xlsx file i've got no problem, but if we made some changes on a excel file with a Mac Pro and try to open it in my project i got this error stacktrace :

```
Wrong Local header signature: 0x4ACF92AD
ICSharpCode.SharpZipLib
```

```
à ICSharpCode.SharpZipLib.Zip.ZipInputStream.GetNextEntry()
à NPOI.OpenXml4Net.Util.ZipInputStreamZipEntrySource..ctor(ZipInputStream inp)
à NPOI.OpenXml4Net.OPC.ZipPackage..ctor(Stream filestream, PackageAccess access)
à NPOI.OpenXml4Net.OPC.OPCPackage.Open(Stream in1)
à NPOI.Util.PackageHelper.Open(Stream is1)
à NPOI.XSSF.UserModel.XSSFWorkbook..ctor(Stream is1)
```

You can found code i wrote below :

```
protected static IWorkbook GetWorkbook(FileInfo file)
{
IWorkbook workBook = null;

using (var stream = file.OpenRead())
{
stream.Position = 0; // <-------- rewind the stream
if (file.Name.ToUpper().EndsWith(".XLSX"))
workBook = new XSSFWorkbook(stream);
else if (file.Name.ToUpper().EndsWith(".XLS"))
workBook = new HSSFWorkbook(stream);
}

return workBook;
}
```

I think i've a problem when we save it on Appel and try to read it on Microsoft system.

How can i do to solve it and allow my project to open Excel file by any possible mean ?

Thanks a lot
Comments: ** Comment from web user: vigotSev **

For information we used "Numbers" software to modify it and convert it in xlsx file.

i think header signature generated doesn't use the same signature algorithm that we get on Microsoft Excel software.

Viewing all 1621 articles
Browse latest View live


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