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

Commented Issue: Error when running NPOI with Mono C# compiler version 2.0.1.0 [4547]

$
0
0
<p>Dear developers,</p>
<p>&nbsp;</p>
<p>I get an error when running applications using NPOI under mono: </p>
<p>&nbsp;</p>
<p>Unhandled Exception: System.ArgumentException: Encoding name &#39;UTF-16LE&#39; not supported</p>
<p>Parameter name: name</p>
<p> at System.Text.Encoding.GetEncoding (System.String name) [0x00000] </p>
<p> at NPOI.Util.StringUtil.PutUnicodeLE (System.String input, System.Byte[] output, Int32 offset) [0x00000]</p>
<p>&nbsp;</p>
<p>Thank you for help,</p>
<p>h2o</p>

Comments: ** Comment from web user: firda **

I have changed it to this while MONO is defined and GOOD_MONO is not (UTF-16 is obviously not working under mono as it should, it is actually working as UTF-16LE which means UTF-16 without BOM)

public static void PutUnicodeLE(String input, byte[] output, int offset)
{
#if !MONO
byte[] bytes = Encoding.GetEncoding("UTF-16LE").GetBytes(input);
Array.Copy(bytes, 0, output, offset, bytes.Length);
#elif GOOD_MONO
byte[] bytes = Encoding.GetEncoding("UTF-16").GetBytes(input);
Array.Copy(bytes, 2, output, offset, bytes.Length - 2);
#else
byte[] bytes = Encoding.GetEncoding("UTF-16").GetBytes(input);
Array.Copy(bytes, 0, output, offset, bytes.Length);
#endif
}
public static void PutUnicodeLE(String input, ILittleEndianOutput out1)
{
byte[] bytes;
try
{
#if !MONO
bytes = Encoding.GetEncoding("UTF-16LE").GetBytes(input);
#else
bytes = Encoding.GetEncoding("UTF-16").GetBytes(input);
#endif
}
catch (EncoderFallbackException)
{
throw;
}
#if !MONO || !GOOD_MONO
out1.Write(bytes);
#else
out1.Write(bytes, 2, bytes.Length - 2);
#endif
}


Commented Issue: Couldnot delete worksheet [11376]

$
0
0
I am trying to delete first sheet from excel file like below
_Worksheet _wsh = (_Worksheet)shs.get_Item(1);
_wsh.Delete();
But it throws error. Am i doing something wrong pls guide.
Comments: ** Comment from web user: gpsushil **

System.ArgumentException was unhandled
HResult=-2147024809
Message=calculated end index (30386) is out of allowable range (30359..30370)
Source=NPOI
StackTrace:
at NPOI.Util.LittleEndianByteArrayOutputStream..ctor(Byte[] buf, Int32 startOffset, Int32 maxWriteLen)
at NPOI.HSSF.Record.StandardRecord.Serialize(Int32 offset, Byte[] data)
at NPOI.HSSF.UserModel.HSSFWorkbook.SheetRecordCollector.Serialize(Int32 offset, Byte[] data)
at NPOI.HSSF.UserModel.HSSFWorkbook.GetBytes()
at NPOI.HSSF.UserModel.HSSFWorkbook.Write(Stream stream)
at UtilExcelHelper.UExcelHelper.Finalize() in D:\Drive E\WFP\for pubish\IndicatorMgmt\IndicatorMgmt\ExcelHelper\UExcelHelper.cs:line 119
at Test.Program.Main(String[] args) in D:\Drive E\WFP\for pubish\IndicatorMgmt\IndicatorMgmt\Test\Program.cs:line 36
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Commented Issue: Error when running NPOI with Mono C# compiler version 2.0.1.0 [4547]

$
0
0
<p>Dear developers,</p>
<p>&nbsp;</p>
<p>I get an error when running applications using NPOI under mono: </p>
<p>&nbsp;</p>
<p>Unhandled Exception: System.ArgumentException: Encoding name &#39;UTF-16LE&#39; not supported</p>
<p>Parameter name: name</p>
<p> at System.Text.Encoding.GetEncoding (System.String name) [0x00000] </p>
<p> at NPOI.Util.StringUtil.PutUnicodeLE (System.String input, System.Byte[] output, Int32 offset) [0x00000]</p>
<p>&nbsp;</p>
<p>Thank you for help,</p>
<p>h2o</p>

Comments: ** Comment from web user: firda **

Latest news:
1. Changing the code from Encoding.GetEncoding("UTF-16LE") to Encoding.Unicode works fine in all versions (both .NET and Mono 2.x and should work in Mono 3.x)
2. Fixed in Mono 3.x (beta - not stable yet)

Created Issue: Access issue creating worksheet [11383]

$
0
0
The following error occurs when we try to create a worksheet. The issue is resolved by setting IIS 7.0 LoadUserProfile to true. We are trying to understand why this is needed and teh secruity implications and if there is a workaround to make this work without having to change the default IIS setting


System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt; System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark&amp; stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Environment.get_UserName()
at NPOI.HSSF.Model.InternalWorkbook.CreateWriteAccess()
at NPOI.HSSF.Model.InternalWorkbook.CreateWorkbook()
at NPOI.HSSF.UserModel.HSSFWorkbook..ctor()
at InfWeb.Segment.DownloadList.PerformDownloadExcel(HttpRequest request, HttpResponse response, iSystemControl system) in C:\Projects\dev_c\InfWeb\Segment\DownloadList.cs:line 725
at InfWeb.Segment.DownloadList.PerformDownload(HttpRequest request, HttpResponse response, iSystemControl system) in C:\Projects\dev_c\InfWeb\Segment\DownloadList.cs:line 549
The action that failed was:
Demand
The type of the first permission that failed was:
System.Security.Permissions.EnvironmentPermission
The first permission that failed was:

version=&quot;1&quot;
Read=&quot;UserName&quot;/&gt;

The demand was for:

version=&quot;1&quot;
Read=&quot;UserName&quot;/&gt;

The granted set of the failing assembly was:

version=&quot;1&quot;&gt;

version=&quot;1&quot;
Access=&quot;Open&quot;/&gt;

version=&quot;1&quot;
Allowed=&quot;ApplicationIsolationByUser&quot;
UserQuota=&quot;512000&quot;/&gt;

version=&quot;1&quot;
Flags=&quot;Execution&quot;/&gt;

version=&quot;1&quot;
Window=&quot;SafeTopLevelWindows&quot;
Clipboard=&quot;OwnClipboard&quot;/&gt;

version=&quot;1&quot;
PublicKeyBlob=&quot;002400000480000094000000060200000024000052534131000400000100010095CCD95AF3B39D8BC20544D3F47FD24B53EBC5CCB693EAED116290629F8CD882C827EBD511AD59449224F0718D3F9D03B64945A6C8B6644266001B8C8426185330E3D96DA70AE16D4ACC21B8D4D480F1385C7E924273179375AA88F81380A72FB115712A313379D16AED4AA36208EE3B4A5DD785B06A07B2D868E3227F4495B5&quot;
Name=&quot;NPOI&quot;
AssemblyVersion=&quot;1.2.5.0&quot;/&gt;

version=&quot;1&quot;
Url=&quot;file:///c:/xxx/web/bin/NPOI.DLL&quot;/&gt;

version=&quot;1&quot;
Zone=&quot;Internet&quot;/&gt;

version=&quot;1&quot;
Level=&quot;SafePrinting&quot;/&gt;


The assembly or AppDomain that failed was:
NPOI, Version=1.2.5.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1
The method that caused the failure was:
NPOI.HSSF.Record.Record CreateWriteAccess()
The Zone of the assembly that failed was:
Internet
The Url of the assembly that failed was:
file:///c:/xxx/web/bin/NPOI.DLL
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct&amp; sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
at ...

Commented Issue: Access issue creating worksheet [11383]

$
0
0
The following error occurs when we try to create a worksheet. The issue is resolved by setting IIS 7.0 LoadUserProfile to true. We are trying to understand why this is needed and teh secruity implications and if there is a workaround to make this work without having to change the default IIS setting<br><br><br>System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt; System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. <br>at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark&amp; stackMark, Boolean isPermSet) <br>at System.Security.CodeAccessPermission.Demand() <br>at System.Environment.get_UserName() <br>at NPOI.HSSF.Model.InternalWorkbook.CreateWriteAccess() <br>at NPOI.HSSF.Model.InternalWorkbook.CreateWorkbook() <br>at NPOI.HSSF.UserModel.HSSFWorkbook..ctor() <br>at ....<br><br>The action that failed was: <br>Demand <br>The type of the first permission that failed was: <br>System.Security.Permissions.EnvironmentPermission <br>The first permission that failed was: <br><br>version=&quot;1&quot; <br>Read=&quot;UserName&quot;/&gt; <br><br>The demand was for: <br><br>version=&quot;1&quot; <br>Read=&quot;UserName&quot;/&gt; <br><br>The granted set of the failing assembly was: <br><br>version=&quot;1&quot;&gt; <br><br>version=&quot;1&quot; <br>Access=&quot;Open&quot;/&gt; <br><br>version=&quot;1&quot; <br>Allowed=&quot;ApplicationIsolationByUser&quot; <br>UserQuota=&quot;512000&quot;/&gt; <br><br>version=&quot;1&quot; <br>Flags=&quot;Execution&quot;/&gt; <br><br>version=&quot;1&quot; <br>Window=&quot;SafeTopLevelWindows&quot; <br>Clipboard=&quot;OwnClipboard&quot;/&gt; <br><br>version=&quot;1&quot; <br>PublicKeyBlob=&quot;002400000480000094000000060200000024000052534131000400000100010095CCD95AF3B39D8BC20544D3F47FD24B53EBC5CCB693EAED116290629F8CD882C827EBD511AD59449224F0718D3F9D03B64945A6C8B6644266001B8C8426185330E3D96DA70AE16D4ACC21B8D4D480F1385C7E924273179375AA88F81380A72FB115712A313379D16AED4AA36208EE3B4A5DD785B06A07B2D868E3227F4495B5&quot; <br>Name=&quot;NPOI&quot; <br>AssemblyVersion=&quot;1.2.5.0&quot;/&gt; <br><br>version=&quot;1&quot; <br>Url=&quot;file:///c:/xxx/web/bin/NPOI.DLL&quot;/&gt; <br><br>version=&quot;1&quot; <br>Zone=&quot;Internet&quot;/&gt; <br><br>version=&quot;1&quot; <br>Level=&quot;SafePrinting&quot;/&gt; <br><br><br>The assembly or AppDomain that failed was: <br>NPOI, Version=1.2.5.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1 <br>The method that caused the failure was: <br>NPOI.HSSF.Record.Record CreateWriteAccess() <br>The Zone of the assembly that failed was: <br>Internet <br>The Url of the assembly that failed was: <br>file:///c:/xxx/web/bin/NPOI.DLL <br>--- End of inner exception stack trace --- <br>at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct&amp; sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) <br>at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) <br>at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) <br>at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) <br>at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args) <br>at ...
Comments: ** Comment from web user: tonyqus **

This should be a bug in NPOI 1.2.5 because the wrong exception is catched.
private static Record CreateWriteAccess()
{
WriteAccessRecord retval = new WriteAccessRecord();

try
{
retval.Username=(Environment.UserName);
}
catch ( AccessViolationException)
{
// AccessControlException can occur in a restricted context
// (client applet/jws application or restricted security server)
retval.Username=("POI");
}
}
AccessViolationException is not the correct exception to be catched. Instead, SecurityException should be used. This bug will be fixed in NPOI 2.0.

New Post: line break in the cell?

$
0
0

It's possible enable line break in the cell?

Reviewed: NPOI 1.2.5 (Nov 27, 2012)

$
0
0
Rated 5 Stars (out of 5) - Very quick and clean solution for my project. I needed to rename the sheets in an Excel document produced by the ReportViewer control. The ReportViewer control only produces the binary Excel format, which NPOI handled without a problem. Thanks for the great work.

Reviewed: NPOI 2.0 (十一月 27, 2012)

$
0
0
Rated 3 Stars (out of 5) - Create *.xlsx file is too slow,how can i improve the speed?

New Post: Create *.xlsx file is too slow

$
0
0

Now I try to create a 2007 Excel file with NPOI 2.0,but it's to slow. If I crate 2003 xls file,it takes 10s,but when I ceate 2007 xlsx file ,it takes about 3min.

How can I improve my speed?

My system is Win7 U 64Bit, VS2010, net 4.0

I need some help.

Thank you! 

Commented Issue: Access issue creating worksheet [11383]

$
0
0
The following error occurs when we try to create a worksheet. The issue is resolved by setting IIS 7.0 LoadUserProfile to true. We are trying to understand why this is needed and teh secruity implications and if there is a workaround to make this work without having to change the default IIS setting<br><br><br>System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt; System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. <br>at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark&amp; stackMark, Boolean isPermSet) <br>at System.Security.CodeAccessPermission.Demand() <br>at System.Environment.get_UserName() <br>at NPOI.HSSF.Model.InternalWorkbook.CreateWriteAccess() <br>at NPOI.HSSF.Model.InternalWorkbook.CreateWorkbook() <br>at NPOI.HSSF.UserModel.HSSFWorkbook..ctor() <br>at ....<br><br>The action that failed was: <br>Demand <br>The type of the first permission that failed was: <br>System.Security.Permissions.EnvironmentPermission <br>The first permission that failed was: <br><br>version=&quot;1&quot; <br>Read=&quot;UserName&quot;/&gt; <br><br>The demand was for: <br><br>version=&quot;1&quot; <br>Read=&quot;UserName&quot;/&gt; <br><br>The granted set of the failing assembly was: <br><br>version=&quot;1&quot;&gt; <br><br>version=&quot;1&quot; <br>Access=&quot;Open&quot;/&gt; <br><br>version=&quot;1&quot; <br>Allowed=&quot;ApplicationIsolationByUser&quot; <br>UserQuota=&quot;512000&quot;/&gt; <br><br>version=&quot;1&quot; <br>Flags=&quot;Execution&quot;/&gt; <br><br>version=&quot;1&quot; <br>Window=&quot;SafeTopLevelWindows&quot; <br>Clipboard=&quot;OwnClipboard&quot;/&gt; <br><br>version=&quot;1&quot; <br>PublicKeyBlob=&quot;002400000480000094000000060200000024000052534131000400000100010095CCD95AF3B39D8BC20544D3F47FD24B53EBC5CCB693EAED116290629F8CD882C827EBD511AD59449224F0718D3F9D03B64945A6C8B6644266001B8C8426185330E3D96DA70AE16D4ACC21B8D4D480F1385C7E924273179375AA88F81380A72FB115712A313379D16AED4AA36208EE3B4A5DD785B06A07B2D868E3227F4495B5&quot; <br>Name=&quot;NPOI&quot; <br>AssemblyVersion=&quot;1.2.5.0&quot;/&gt; <br><br>version=&quot;1&quot; <br>Url=&quot;file:///c:/xxx/web/bin/NPOI.DLL&quot;/&gt; <br><br>version=&quot;1&quot; <br>Zone=&quot;Internet&quot;/&gt; <br><br>version=&quot;1&quot; <br>Level=&quot;SafePrinting&quot;/&gt; <br><br><br>The assembly or AppDomain that failed was: <br>NPOI, Version=1.2.5.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1 <br>The method that caused the failure was: <br>NPOI.HSSF.Record.Record CreateWriteAccess() <br>The Zone of the assembly that failed was: <br>Internet <br>The Url of the assembly that failed was: <br>file:///c:/xxx/web/bin/NPOI.DLL <br>--- End of inner exception stack trace --- <br>at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct&amp; sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) <br>at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) <br>at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) <br>at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) <br>at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args) <br>at ...
Comments: ** Comment from web user: meerashan **

Thanks. I made the change and it worked.

New Post: Create *.xlsx file is too slow

$
0
0

This is a known issue. We will try to improve somewhat in the final release of NPOI 2.0. However, the root cause may be the xml serialization in .NET using XmlSerializer. We are looking for alternative solutions for this. In java, POI use XmlBean, which is more efficient than .NET Xml.

New Post: line break in the cell?

New Post: Create *.xlsx file is too slow

$
0
0
tonyqus wrote:

This is a known issue. We will try to improve somewhat in the final release of NPOI 2.0. However, the root cause may be the xml serialization in .NET using XmlSerializer. We are looking for alternative solutions for this. In java, POI use XmlBean, which is more efficient than .NET Xml.

Thank U

New Post: use vb.net to create xls file from .net table using NPOI

$
0
0

I have never seen NpoiExport class before. It should be a third-party wrapper for NPOI. Please reference the third-party document.

New Post: Where are the ss.format classs coming from?

$
0
0

I see NPOI.SS.Format.CellFormat*, but failed to find it in the source code - what's going on?


New Post: Where are the ss.format classs coming from?

$
0
0

Also, are the CellFormat* classes supported? I ran a quick test and it didn't work at all.

Commented Issue: Couldnot delete worksheet [11376]

$
0
0
I am trying to delete first sheet from excel file like below
_Worksheet _wsh = (_Worksheet)shs.get_Item(1);
_wsh.Delete();
But it throws error. Am i doing something wrong pls guide.
Comments: ** Comment from web user: gpsushil **

I have posted exception detail above. Pls guide me on this. I even tried
hssfworkbook.Workbook.RemoveSheet(0);
but no success

New Post: Where are the ss.format classs coming from?

$
0
0

The latest code is in googlecode svn: <cite>npoi.googlecode.com</cite>

Commented Issue: CreateDrawingPatriarch only works once [11330]

$
0
0
NPOI 2.0 alpha<br>
<br>
When using XSSH and invoking CreateDrawingPatriarch() on a sheet only the first call will return an IDrawing object. Subsequent calls will return null.<br>
<br>
Sample Code:<br>
<br>
<p>private static void SetCellComment(ISheet worksheet, int columnPosition, int rowPosition, string comment)<br>
{<br>
//Get row<br>
var row = worksheet.GetRow(rowPosition) ?? worksheet.CreateRow(rowPosition);</p>

<p> //Get or Create Cell<br>
var cell = row.GetCell(columnPosition) ?? row.CreateCell(columnPosition);<br>
<br>
//We need a drawing patriarch as a graphics surface.<br>
var drawingSurface = worksheet.CreateDrawingPatriarch();</p>

<p> //The creation helper can provide basic objects.<br>
var objectFactory = worksheet.Workbook.GetCreationHelper();</p>

<p> //Create the new comment.<br>
var newComment = drawingSurface.CreateCellComment(objectFactory.CreateClientAnchor());<br>
newComment.String = objectFactory.CreateRichTextString(comment);</p>

<p> //Link the comment to the desired cell.<br>
cell.CellComment = newComment;<br>
}</p>
Comments: ** Comment from web user: tonyqus **

The latest code is in googlecode SVN instead of codeplex svn.

Commented Issue: Error evaluating cell on excel PV function [11265]

$
0
0
I receive an 'error evaluating cell' message when running the EvaluateAllFormulaCells method on an xls that has a cell with the present value function PV. i do not receive the error on any other formulas.

Please see my code below and let me know if any ideas. Thanks!

HSSFWorkbook xssfwb;
using (FileStream file = new FileStream(@&quot;c:\Book1.xls&quot;, FileMode.Open, FileAccess.ReadWrite))
{
xssfwb = new HSSFWorkbook(file);
HSSFFormulaEvaluator.EvaluateAllFormulaCells(xssfwb);
}
Comments: ** Comment from web user: tonyqus **

Can you share the xls with me? Please send it to tonyqus (at) gmail.com

Viewing all 1621 articles
Browse latest View live


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