New Post: Writing image to HSSFHeader and HSSFFooter
Reviewed: NPOI 1.2.5 (авг 25, 2016)
Created Unassigned: IPatternFormatting.FillPattern should be of type FillPattern, not short [13973]
I just noticed that I missed IPatternFormatting.FillPattern.
Created Unassigned: XSSFPatternFormatting does not have a way to set an XSSFColor [13974]
I'm hoping it's just something that's been overlooked :)
For now I can just use the IndexedColors, so this isn't a high priority...
Commented Unassigned: IPatternFormatting.FillPattern should be of type FillPattern, not short [13973]
I just noticed that I missed IPatternFormatting.FillPattern.
Comments: ** Comment from web user: jstedfast **
I've submitted a PR to fix this here: https://github.com/tonyqus/npoi/pull/98
Commented Unassigned: XSSFPatternFormatting does not have a way to set an XSSFColor [13974]
I'm hoping it's just something that's been overlooked :)
For now I can just use the IndexedColors, so this isn't a high priority...
Comments: ** Comment from web user: jstedfast **
I gave a quick look at the code last night and I *suspect* that I could probably clone the logic from XSSFCellStyle's `SetFillForegroundColor(XSSFColor)` over to XSSFPatternFormatting, but I am just guessing :)
Commented Unassigned: Incorrect value of calculation with INT operator [13924]
```
var workbook = new HSSFWorkbook();
var sheet = workbook.CreateSheet();
var row = sheet.CreateRow(0);
var cell = row.CreateCell(0);
var evaluator = workbook.GetCreationHelper().CreateFormulaEvaluator();
// should be 6.0 => OK
cell.SetCellFormula("INT(6.99)");
var cellValue = evaluator.Evaluate(cell);
var result = cellValue.NumberValue;
// should be 6.0 => KO : 7.0 is returned
var cell1 = row.CreateCell(1);
cell1.SetCellFormula("INT(6.991)");
var cellValue1 = evaluator.Evaluate(cell1);
var result1 = cellValue1.NumberValue;
// should be 6.0 => OK
var cell2 = row.CreateCell(2);
cell2.SetCellFormula("INT(6.9900000000000005)");
var cellValue2 = evaluator.Evaluate(cell2);
var result2 = cellValue2.NumberValue;
// should be 6.0 => KO : 7.0 is returned
var cell3 = row.CreateCell(3);
cell3.SetCellFormula("INT(6.9900000000000007)");
var cellValue3 = evaluator.Evaluate(cell3);
var result3 = cellValue3.NumberValue;
```
Am I doing something wrong ?
Comments: ** Comment from web user: brobic **
Hello,
I have exactly the same problem.
Have you found a solution to resolve it?
It generates multiple bugs in our application...
Thanks by advance.
New Post: How To Convert Shape to Image
here snippet of my code :
var dr = workbook.GetSheetAt(sht).DrawingPatriarch;
HSSFPatriarch pat = (HSSFPatriarch)dr;
var shape = pat.Children;
int i = 0;
foreach (var s in shape)
{
string patType = s.GetType().ToString();
switch (patType)
{
case "NPOI.HSSF.UserModel.HSSFSimpleShape":
{
var simpleshape = (HSSFSimpleShape)s;
/*Save Shape*/
break;
}
case "NPOI.HSSF.UserModel.HSSFPicture":
{
var pic = (HSSFPicture)s;
byte[] data = pic.PictureData.Data;
/*Code to Save Image From Byte[]*/
break;
}
default: break;
}
}
With that code I'm able to get all images and shapes that I want, but I can only Save ImageData (HSSFPicture) to directory, and I can't find any method to Save Shapes Data (HSSFSimpleShape) or convert it to Image.Question is, how to convert HSSFSimpleShape data to Image? Is that Possible? Is there anything I miss?
Hope Someone can help, Thanks
Commented Unassigned: Incorrect value of calculation with INT operator [13924]
```
var workbook = new HSSFWorkbook();
var sheet = workbook.CreateSheet();
var row = sheet.CreateRow(0);
var cell = row.CreateCell(0);
var evaluator = workbook.GetCreationHelper().CreateFormulaEvaluator();
// should be 6.0 => OK
cell.SetCellFormula("INT(6.99)");
var cellValue = evaluator.Evaluate(cell);
var result = cellValue.NumberValue;
// should be 6.0 => KO : 7.0 is returned
var cell1 = row.CreateCell(1);
cell1.SetCellFormula("INT(6.991)");
var cellValue1 = evaluator.Evaluate(cell1);
var result1 = cellValue1.NumberValue;
// should be 6.0 => OK
var cell2 = row.CreateCell(2);
cell2.SetCellFormula("INT(6.9900000000000005)");
var cellValue2 = evaluator.Evaluate(cell2);
var result2 = cellValue2.NumberValue;
// should be 6.0 => KO : 7.0 is returned
var cell3 = row.CreateCell(3);
cell3.SetCellFormula("INT(6.9900000000000007)");
var cellValue3 = evaluator.Evaluate(cell3);
var result3 = cellValue3.NumberValue;
```
Am I doing something wrong ?
Comments: ** Comment from web user: ebyrob **
This is controlled in the source code here:
main\SS\Formula\Functions\Int.cs
public class Int : OneArg
{
public override double Evaluate(double d)
{
if (d > 0)
return Math.Round(d - 0.49);
else
return Math.Round(d - 0.5);
}
}
Should be Math.Floor(d) instead of Round I think.
Updated Wiki: Home
Neuzilla is the studio behind NPOI. For detail, you can check http://blog.neuzilla.com/.
c. extract images from Office documents
E-iceblue is a community sponsor of NPOI. 提供中文技术支持 |
Don't forget to have a try on Free Spire.XLS |
支付宝捐款账号: tonyqus@163.com
Paypal: tonyqus@gmail.com
NPOI on SNS
System Requirement
VS2005 or VS2008 with .NET 2.0 Runtime (SP1)
vs2003 with .NET 1.1
medium trust environment in ASP.NET
Updated Wiki: Home
Neuzilla is the studio behind NPOI. For detail, you can check http://blog.neuzilla.com/.
c. extract images from Office documents
E-iceblue is a community sponsor of NPOI. 提供中文技术支持 |
Don't forget to have a try on Free Spire.XLS |
支付宝捐款账号: tonyqus@163.com
Paypal: tonyqus@gmail.com
NPOI on SNS
System Requirement
VS2005 or VS2008 with .NET 2.0 Runtime (SP1)
vs2003 with .NET 1.1
medium trust environment in ASP.NET
Commented Unassigned: Incorrect value of calculation with INT operator [13924]
```
var workbook = new HSSFWorkbook();
var sheet = workbook.CreateSheet();
var row = sheet.CreateRow(0);
var cell = row.CreateCell(0);
var evaluator = workbook.GetCreationHelper().CreateFormulaEvaluator();
// should be 6.0 => OK
cell.SetCellFormula("INT(6.99)");
var cellValue = evaluator.Evaluate(cell);
var result = cellValue.NumberValue;
// should be 6.0 => KO : 7.0 is returned
var cell1 = row.CreateCell(1);
cell1.SetCellFormula("INT(6.991)");
var cellValue1 = evaluator.Evaluate(cell1);
var result1 = cellValue1.NumberValue;
// should be 6.0 => OK
var cell2 = row.CreateCell(2);
cell2.SetCellFormula("INT(6.9900000000000005)");
var cellValue2 = evaluator.Evaluate(cell2);
var result2 = cellValue2.NumberValue;
// should be 6.0 => KO : 7.0 is returned
var cell3 = row.CreateCell(3);
cell3.SetCellFormula("INT(6.9900000000000007)");
var cellValue3 = evaluator.Evaluate(cell3);
var result3 = cellValue3.NumberValue;
```
Am I doing something wrong ?
Comments: ** Comment from web user: Scampeon **
Thanks a lot !
This code corrects the problem
```
public class Int : OneArg
{
public override double Evaluate(double d)
{
return Math.Floor(d);
}
}
```
Both Excel and Math.Floor give the same result
```
- INT(-2) => -2
- INT(-1,9) => -2
- INT(-2,1) => -3
- INT(6,99) => 6
- INT(6,991) => 6
- INT(6,9900000000000005) => 6
- INT(6,9900000000000007) => 6
- Math.Floor(-2) => -2
- Math.Floor(-1.9) => -2
- Math.Floor(-2.1) => -3
- Math.Floor(6.99) => 6
- Math.Floor(6.991) => 6
- Math.Floor(6.9900000000000005) => 6
- Math.Floor(6.9900000000000007) => 6
```
New Post: Conditional Format is not work for XSSFWorkbook
is this a bug?
HSSFWorkbook wk = new HSSFWorkbook(); // 2003
//XSSFWorkbook wk = new XSSFWorkbook(); // 2007
ISheet sheet = wk.CreateSheet("Report");
ISheetConditionalFormatting ConditionalFormatting = sheet.SheetConditionalFormatting;
IConditionalFormattingRule LessThan1_33 = ConditionalFormatting.CreateConditionalFormattingRule(ComparisonOperator.LessThan, "1.33", null);
IPatternFormatting patternFmt1 = LessThan1_33.CreatePatternFormatting();
patternFmt1.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.Red.Index;
CellRangeAddress[] regions1 = { new CellRangeAddress(1, Designators.Count, 8, 8) };
ConditionalFormatting.AddConditionalFormatting(regions1, LessThan1_33);
Updated Wiki: Temporary Post Used For Theme Detection (634c749c-1bfd-4fed-ba30-a0b812defd82 - 3bfe001a-32de-4114-a6b4-4005b770f6d7)
This is a temporary post that was not deleted. Please delete this manually. (7aff0fb3-b046-410b-b5db-112606f50c57 - 3bfe001a-32de-4114-a6b4-4005b770f6d7)
Created Unassigned: RecordFormatException: Unable to construct record instance [13988]
Inner Exception: {"Unknown encryption info 4"}.
Adding the code I have used to process this..
FileStream file = new FileStream(filefullPath, FileMode.Open, FileAccess.Read);
Biff8EncryptionKey.CurrentUserPassword = password;
IWorkbook hssfworkbook = new HSSFWorkbook(file);
Please advice.. I am not able to find.. what is causing this issue..
Attached exception details in the screenshot below..
New Post: Problem working with Excel 2007
New Post: Formula recalculation
Unexpected eval class (MissingArgEval) in NPOI.HSSF.UserModel.HSSFFormulaEvaluator.EvaluateFormulaCellValue(ICell cell)
in NPOI.HSSF.UserModel.HSSFFormulaEvaluator.EvaluateFormulaCell(ICell cell)
in NPOI.HSSF.UserModel.HSSFFormulaEvaluator.EvaluateAllFormulaCells(IWorkbook wb, IFormulaEvaluator evaluator)
in NPOI.HSSF.UserModel.HSSFFormulaEvaluator.EvaluateAllFormulaCells(HSSFWorkbook wb)
I don't understand which cell cause the Error.
It's possibile the download the source code of the last version of NOI?
Created Unassigned: EvaluateAllFormulaCells error [13992]
Unexpected eval class (MissingArgEval) in NPOI.HSSF.UserModel.HSSFFormulaEvaluator.EvaluateFormulaCellValue(ICell cell)
in NPOI.HSSF.UserModel.HSSFFormulaEvaluator.EvaluateFormulaCell(ICell cell)
in NPOI.HSSF.UserModel.HSSFFormulaEvaluator.EvaluateAllFormulaCells(IWorkbook wb, IFormulaEvaluator evaluator)
in NPOI.HSSF.UserModel.HSSFFormulaEvaluator.EvaluateAllFormulaCells(HSSFWorkbook wb)
I don't understand which cell cause the Error.
It's possibile the download the source code of the last version of NOI or know the cell that cause the error?
thanks
Reviewed: NPOI 2.1.3.1 (十月 15, 2016)
Created Unassigned: The supplied POIFSFileSystem does not contain a BIFF8 'Workbook' entry. Is it really an excel file? [13997]
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.