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

Commented Unassigned: 2007 format Excel file corrupted [13809]

$
0
0
We use NPOI to modify an existing template and save it as a new one.
The new Excel file created by NOPI is always corrupted. When the file is opened, it says' We found a problem with some content in 'FileName.xlsx'.Do you want us to try to recover as much as we can? If you trust the source of this workbook, Click Yes" (发现FileName.xlsx 中部分内容有问题。是否让我们尽量尝试恢复?如果您信任次工作簿的源,请单击是)
We narrow down the condition, just use NPOI to open it and then save as a new file. The file will be corrupted.
We try the newest version 2.2.0, but in vain.
Comments: ** Comment from web user: Hellissimo **

Hi

try maybe this 2 small examples:

Reading example:

```
private IWorkbook InitializeIWorkbook(string path)
{
try
{
IWorkbook workbook = null;
using (FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
FileInfo fileInfo = new FileInfo(path);
if (fileInfo.Extension.ToLower() == ".xlsx" || fileInfo.Extension.ToLower() == ".xlsm")
{
// Excel 2007+
workbook = new XSSFWorkbook(file);
}
if (fileInfo.Extension.ToLower() == ".xls" || fileInfo.Extension.ToLower() == ".xlm")
{
// Excel 2003
workbook = new HSSFWorkbook(file);
}
}
return workbook;
}
catch (IOException e)
{
MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
}
```
Writing example:

```
public void FileStreamToExcel()
{
try
{
// speichern
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
{
workbook.Write(fs);
}
}
catch (IOException e)
{
MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
```

In the most cases it is a problem of FileStream...


Commented Unassigned: Broken XLSX [13792]

$
0
0
Hi, I have several problematic XLSX files. When I try to open and save them result file is broken and can not be opened by excel.
Can you tell me what is wrong with the files ?

Thanks
Comments: ** Comment from web user: Hellissimo **

I think it is the same issue like this:

__"corrupt XLSX file after reference (formula) to a CellValue, which contains a '&' sign"__

[TEXT](https://npoi.codeplex.com/workitem/13893)

at the moment, I am searching for a solution.

Commented Unassigned: XLSX file gets corrupted when write it using NPOI latest version [13546]

$
0
0
Hi Team,

I have downloaded NPOI 2.1.3 latest version from https://npoi.codeplex.com/releases.

When i am writing XLSX file using this dll then program successfully writes the rows (no error comes). but when i try to open the excel file then i get following error:

"Excel cannot open the file 'xyz.xlsx' because the file format or file extension
is not valid. Verify that the file has not been corrupted and the file extension matches the format of the fie."


I have wrote below code to wrote excel. Can you please help on this.

XSSFWorkbook xssfwb = new XSSFWorkbook();
IWorkbook iworkbook;


using (FileStream file = new FileStream(@"D:\XYZ.xlsx", FileMode.Open, FileAccess.Read))
{
hssfwb = new HSSFWorkbook(file);
iworkbook = hssfwb;
file.Close(); }

ISheet sheet1 = xssfwb.GetSheetAt(0);
for (int i = 1; i <= dt.Rows.Count; i++) //dt is a datatable which contain data to write into excel
{
IRow row = sheet1.CreateRow(i + 1);
for (int j = 0; j < 20; j++)
{
row.CreateCell(j).SetCellValue(x++); }
}

using (FileStream file = new FileStream(@"D:\XYZ.xlsx", FileMode.Open, FileAccess.Write))
{
hssfwb.Write(file);
file.Close();
}
Comments: ** Comment from web user: Hellissimo **

Hi,

maybe try this 2 small examples for reading and writing XLSX:

[issue: 13809](https://npoi.codeplex.com/workitem/13809)

Created Unassigned: Shift Rows Throws Null Reference Exception when sheet has comments. [13894]

$
0
0
I am trying delete a row from my excel sheet which has comments on some of the cells. When calling shift rows to do this I get a null reference exceptions which appears to be stemming from the update of the comments references. Below is a stacktrace. This makes the library effectively unable to delete rows which seems like a pretty significant issue.

Object reference not set to an instance of an object.
at NPOI.XSSF.Model.CommentsTable.RecreateReference()
at NPOI.XSSF.UserModel.XSSFSheet.ShiftRows(Int32 startRow, Int32 endRow, Int32 n, Boolean copyRowHeight, Boolean reSetOriginalRowHeight)
at NPOI.XSSF.UserModel.XSSFSheet.ShiftRows(Int32 startRow, Int32 endRow, Int32 n)
at UserQuery.EmpReportGenerator.ProcessSheetData(ISheet sheet, List`1 data)
at UserQuery.EmpReportGenerator.Generate()
at UserQuery.Main()

New Post: Resolve filename for external links in formulas - ExternalLinksTable

$
0
0
I've been unsuccessful in getting the ExternalLinksTable from a workbook.

The $cell.CellFormula is: [1]Sheet1!$B$2 where [1] references an external workbook.

Using NPOI, how can I find the name of the external sheet? Basically expand the formula to include the external workbook name?

getExternalLinksTable() is not found.
$wb.getExternalLinksTable();

This seems to be in POI, but I've been unsuccessful using this with NPOI.

New Post: Resolve filename for external links in formulas - ExternalLinksTable

$
0
0
May have found the answer - downloaded the beta version of NPOI and ExternalLinksTable is there.

Is there any other option in resolving the path for [1] in the formula above?

Created Unassigned: 数据有效性错误 [13896]

$
0
0
我添加了一个数据有效性的验证:"AND(ISNUMBER(A1), COUNTIF(A: A, A1) = 1)"

CellRangeAddressList regions = new CellRangeAddressList(1, 65535, i, i);
string formula = "AND(ISNUMBER(A1), COUNTIF(A: A, A1) = 1)";

IDataValidationConstraint constraint = ivh.CreateCustomConstraint(formula);
IDataValidation dataValidate = ivh.CreateValidation(constraint, regions);
dataValidate.CreateErrorBox("error", "数据类型错误");
sheet_tb.AddValidationData(dataValidate);

我必须点击 "数据有效性">"确定"才能正常验证,否则验证总是不通过的

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
 

Updated Release: NPOI 2.2.1

$
0
0
Bug Fixes
- Fix weird XSSF CellStyle Border behaviour
- 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

Updated Release: NPOI 2.2.1

$
0
0
Bug Fixes
- Fix weird XSSF CellStyle Border behaviour
- 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

Updated Release: NPOI 2.2.1

$
0
0
Bug Fixes
- Fix weird XSSF CellStyle Border behaviour
- 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

$
0
0
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 (五月 21, 2016)

$
0
0
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.1.3.1 (二月 22, 2015)

$
0
0
关注官方微信公众号, 请搜索"架构师联盟"

BUG FIXES
a. fix word serialization issues
b. fix CloneStyleFrom issue
c. Fix vertical alignment default value for XSSFCell
d. fix setAutoFilter change range issue
e. fix EDate function
f. fix FormatException in FormulaParser
g. fix Comment random Shape issue (comment serialization issue)
h. fix not be able to unlock the cell issue

POI BUG FIXES
55729 - DataFormatter should format Error cells, returning the Excel error string
49237 - HSSF Row Style XfIndex is 12 not 16 bits of data
54607 - NullPointerException in XSSFSheet.getTopRow() when the top row is 1
55745 - fix handling of tables in XSSF if there are comments as well
54673 - Simple wildcard support in HLOOKUP, VOOLKUP, MATCH, COUNTIF
55047 - REPT formula support
55042 - COMPLEX formula support
55041 - CODE formula support
54508 - EDATE formula support
53966 - IfError support (from Analysis Toolpak)
54402 - IfError handling of indirect references

NEW FEATURES
a. Add ReplaceText to XWPFParagraph and XWPFRun
b. adjust ExcelExtractor interface
c. Improving comment missing handling in HSSFSheet
d. copy hyperlink in CopySheet and fix some bugs
e. Implement ChartSheet in OpenXmlFormats
f. Implement shrinktofit for XSSF

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

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

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


Released: NPOI 2.1.3.1 (Feb 22, 2015)

$
0
0
关注Neuzilla官方微信公众号, 请搜索"架构师联盟"或neuzilla

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

BUG FIXES
a. fix word serialization issues
b. fix CloneStyleFrom issue
c. Fix vertical alignment default value for XSSFCell
d. fix setAutoFilter change range issue
e. fix EDate function
f. fix FormatException in FormulaParser
g. fix Comment random Shape issue (comment serialization issue)
h. fix not be able to unlock the cell issue

POI BUG FIXES
55729 - DataFormatter should format Error cells, returning the Excel error string
49237 - HSSF Row Style XfIndex is 12 not 16 bits of data
54607 - NullPointerException in XSSFSheet.getTopRow() when the top row is 1
55745 - fix handling of tables in XSSF if there are comments as well
54673 - Simple wildcard support in HLOOKUP, VOOLKUP, MATCH, COUNTIF
55047 - REPT formula support
55042 - COMPLEX formula support
55041 - CODE formula support
54508 - EDATE formula support
53966 - IfError support (from Analysis Toolpak)
54402 - IfError handling of indirect references

NEW FEATURES
a. Add ReplaceText to XWPFParagraph and XWPFRun
b. adjust ExcelExtractor interface
c. Improving comment missing handling in HSSFSheet
d. copy hyperlink in CopySheet and fix some bugs
e. Implement ChartSheet in OpenXmlFormats
f. Implement shrinktofit for XSSF

Updated Release: NPOI 2.1.3.1 (二月 22, 2015)

$
0
0
关注Neuzilla官方微信公众号, 请搜索"架构师联盟"或neuzilla

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

BUG FIXES
a. fix word serialization issues
b. fix CloneStyleFrom issue
c. Fix vertical alignment default value for XSSFCell
d. fix setAutoFilter change range issue
e. fix EDate function
f. fix FormatException in FormulaParser
g. fix Comment random Shape issue (comment serialization issue)
h. fix not be able to unlock the cell issue

POI BUG FIXES
55729 - DataFormatter should format Error cells, returning the Excel error string
49237 - HSSF Row Style XfIndex is 12 not 16 bits of data
54607 - NullPointerException in XSSFSheet.getTopRow() when the top row is 1
55745 - fix handling of tables in XSSF if there are comments as well
54673 - Simple wildcard support in HLOOKUP, VOOLKUP, MATCH, COUNTIF
55047 - REPT formula support
55042 - COMPLEX formula support
55041 - CODE formula support
54508 - EDATE formula support
53966 - IfError support (from Analysis Toolpak)
54402 - IfError handling of indirect references

NEW FEATURES
a. Add ReplaceText to XWPFParagraph and XWPFRun
b. adjust ExcelExtractor interface
c. Improving comment missing handling in HSSFSheet
d. copy hyperlink in CopySheet and fix some bugs
e. Implement ChartSheet in OpenXmlFormats
f. Implement shrinktofit for XSSF

Released: NPOI 2.2.1 (May 21, 2016)

$
0
0
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 (五月 21, 2016)

$
0
0
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

Released: NPOI 2.2.1 (May 21, 2016)

$
0
0
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

Viewing all 1621 articles
Browse latest View live


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