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

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.

New Post: ICellStyle

$
0
0
I have the same code to generate XLS and XLSX and I use SS.UserModel interfaces.
    If Excel2007 Then
        oWorkBook = New NPOI.XSSF.UserModel.XSSFWorkbook()
    Else
        oWorkBook = New NPOI.HSSF.UserModel.HSSFWorkbook()
    End If
When I create ICellStyles with oWorkBook.CreateCellStyle(), if I change i.e FillForegroundColor property of iCellStyle A, also other iCellStyles change the same property...
    Dim csNormal As ICellStyle, csCOL As ICellStyle
    csNormal = oWorkBook.CreateCellStyle()
    csNormal.WrapText = False
    csNormal.SetFont(fNormal)

    csCOL = oWorkBook.CreateCellStyle()
    csCOL.CloneStyleFrom(csNormal)
    csCOL.FillForegroundColor = IndexedColors.Grey25Percent.Index
WHY (csNormal..FillForegroundColor == IndexedColors.Grey25Percent.Index) ALSO?


Thank you for your help.

New Post: Anyone help to fix error (xls->html)

$
0
0
Dear All,

Error on null return ($filepath), Please help to fix problem. Thanks.
$filepath = New-Object IO.FileStream "c:\ps\testa.xlsx", "Append", "Write", "Read"
$workbook.ExcelToHtmlUtils.LoadXls($filepath)

Powershell code as below:

[void][System.Reflection.Assembly]::LoadFile("c:\ps\NPOI.dll")
[void][System.Reflection.Assembly]::LoadFile("c:\ps\NPOI.OOXML.dll")
[void][System.Reflection.Assembly]::LoadFile("c:\ps\NPOI.OpenXml4Net.dll")
[void][System.Reflection.Assembly]::LoadFile("c:\ps\NPOI.OpenXmlFormats.dll")
[void][System.Reflection.Assembly]::LoadFile("c:\ps\ICSharpCode.SharpZipLib.dll")

$workbook = new-object NPOI.XSSF.UserModel.XSSFWorkbook
$filepath = New-Object IO.FileStream "c:\ps\testa.xlsx", "Append", "Write", "Read"
$workbook.ExcelToHtmlUtils.LoadXls($filepath)

$ExcelToHtmlConverter = new-object NPOI.SS.Converter.ExcelToHtmlConverter;

$excelToHtmlConverter.OutputColumnHeaders = $false;
$excelToHtmlConverter.OutputHiddenColumns = $true;
$excelToHtmlConverter.OutputHiddenRows = $true;
$excelToHtmlConverter.OutputLeadingSpacesAsNonBreaking = $false;
$excelToHtmlConverter.OutputRowNumbers = $true;
$excelToHtmlConverter.UseDivsToSpan = $true;

$excelToHtmlConverter.ProcessWorkbook($workbook)

$excelToHtmlConverter.Document.Save([IO.Path]::ChangeExtension($filepath,"html"))

$filepath.Close()
$filepath.Dispose()

New Post: ExternalLinks referenced in an Excel sheet of type .xls and .xlsx

$
0
0
I am new to NPOI development. Currently, working on a project involving NPOI. I have a scenario where I need to parse all cells in an Excel sheet to find out formulas and ExternalLinks, if any. I was successfull in finding out the formulas underneath a cell but not the External links.I was able to get the value of the file the external link is pointing to (for example, '[Test.xls]Guest') but not the full path like "='C:\Files[Test.xls]Guest'!F13" the cell underneath is pointing to. I used "cell_Active.CellFormula.ToString()" to get the value '[Test.xls]Guest' but not the full path. I read several documents on internet but couldn't get what I need.
My simple question: How to get ExternalLinks referenced in an Excel sheet of type .xls and .xlsx? If I am not wrong, we need to use HSSF for files of type .xls and XSSF for files of type .xlsx.

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.

New Post: line break in the cell?

$
0
0
How do I put a line break in a cell when I need subscript and superscript in the same cell? XSSFRichTextString seems to remove the line breaks...

New Post: Greek letter in english text

$
0
0
I would like to use a greek letter in a cell which contains an english text. Like 'alpha is the first greek letter.' where alpha should be displayes as the greek letter. Is there a way to include a unicode symbol?

New Post: Greek letter in english text

$
0
0
Found the answer. It is as simple as "\u03b1 is the first greek letter".

New Post: write to .xls file silently fails

$
0
0
Greetings,

I am able to read from an .xls file using HSSF's methods but when I try to write back to the file, the write silently fails with no error messages. I have unlocked the cells, but the sheets are still protected, and when I call the UnWriteProtectWorkbook() method, I get an index out of range error. I do not know whether the fact that the sheets are protected is the issue, especially given that the cells are all unlocked. I am using the SetCellValue method with a Convert.ToDouble cast inside it in C#. I have confirmed that I can manually update cells in Excel itself.

What are some of the most common causes of this type of silent error? Thank you!

Regards,

Theresa
Providence, Rhode Island

New Post: AutoSizeColumn got slow in NPOI 2.0

$
0
0
Any progress on this? I'm on version 2.1.0 and AutoSizeColumn is extremely slow. It takes up to 20s to process a small document.

Side note: since codeplex is shutting down, wouldn't it be best to allow people to create issues on Github?

New Post: Different behavior in ShiftRows with .xls and .xlsx in NPOI 2.3.0

$
0
0
There is a different behavior between shifting rows in .xls and .xlsx files. I have a snippet below which I use to copy rows. In 2.2.3, it was broken for .xlsx but a user told me here that it is fine now: http://stackoverflow.com/questions/41369004/npoi-poi-excel-lib-isheet-shiftrows-index-out-of-range-exception.

Here's my function:
public void CopyRow(IWorkbook iWorkbook, ISheet iSheet, int sourceRowNum, int destinationRowNum)
    {
        // Get the source / new row
        IRow newRow = iSheet.GetRow(destinationRowNum);
        IRow sourceRow = iSheet.GetRow(sourceRowNum);

        if (newRow == null)
        {
            iSheet.CreateRow(destinationRowNum);
            newRow = iSheet.GetRow(destinationRowNum);
        }

        if (newRow.RowNum != destinationRowNum)
        {
            destinationRowNum = newRow.RowNum;
        }

        // If the row exist in destination, push down all rows by 1 else create a new row
        if (newRow != null)
        {
            iSheet.ShiftRows(destinationRowNum, iSheet.LastRowNum, 1);
        }
        else
        {
            newRow = iSheet.CreateRow(destinationRowNum);
        }

        //newRow = iSheet.GetRow(destinationRowNum);

        // Loop through source columns to add to new row
        for (int i = 0; i < sourceRow.LastCellNum; i++)
        {
            // Grab a copy of the old/new cell
            ICell oldCell = sourceRow.GetCell(i);
            ICell newCell = newRow.CreateCell(i);

            // If the old cell is null jump to next cell
            if (oldCell == null)
            {
                newCell = null;
                continue;
            }

            // Copy style from old cell and apply to new cell
            //ICellStyle newCellStyle = iWorkbook.CreateCellStyle();
            //newCellStyle.CloneStyleFrom(oldCell.CellStyle);
            //;
            //newCell.CellStyle = newCellStyle;
            newCell.CellStyle = oldCell.CellStyle;

            // If there is a cell comment, copy
            if (oldCell.CellComment != null)
            {
                newCell.CellComment = oldCell.CellComment;
            }

            // If there is a cell hyperlink, copy
            if (oldCell.Hyperlink != null)
            {
                newCell.Hyperlink = oldCell.Hyperlink;
            }

            // Set the cell data type
            newCell.SetCellType(oldCell.CellType);

            // Set the cell data value
            switch (oldCell.CellType)
            {
                case CellType.Blank:
                    newCell.SetCellValue(oldCell.StringCellValue);
                    break;
                case CellType.Boolean:
                    newCell.SetCellValue(oldCell.BooleanCellValue);
                    break;
                case CellType.Error:
                    newCell.SetCellErrorValue(oldCell.ErrorCellValue);
                    break;
                case CellType.Formula:
                    newCell.SetCellFormula(oldCell.CellFormula);
                    break;
                case CellType.Numeric:
                    newCell.SetCellValue(oldCell.NumericCellValue);
                    break;
                case CellType.String:
                    newCell.SetCellValue(oldCell.RichStringCellValue);
                    break;
            }
        }

        // If there are are any merged regions in the source row, copy to new row
        for (int i = 0; i < iSheet.NumMergedRegions; i++)
        {
            CellRangeAddress cellRangeAddress = iSheet.GetMergedRegion(i);
            if (cellRangeAddress.FirstRow == sourceRow.RowNum)
            {
                CellRangeAddress newCellRangeAddress = new CellRangeAddress(newRow.RowNum,
                          (newRow.RowNum +
                                     (cellRangeAddress.LastRow - cellRangeAddress.FirstRow
                                                )),
                          cellRangeAddress.FirstColumn,
                          cellRangeAddress.LastColumn);
                iSheet.AddMergedRegion(newCellRangeAddress);
            }
        }
    }
If you step through it using an .xls file, it works as it did in NPOI 2.2.3. However, using an .xlsx file, the newRow.RowNum increases + 1 from the original destinationRowNum it was set to after calling ShiftRows, while with an .xls the newRow.RowNum stays the same. This ends up with null reference exceptions. Anyone have a workaround or know why they behave differently?

New Post: UnprotectWorkbook() yields index out of range under multiple conditions

$
0
0
Greetings,

I have an .xls file with a single tab and a contiguous block of cells with no nulls. I have made sure there are no extraneous empty rows or columns trailing my data. The UnprotectWorkbook() function yields index out of range on its list of records regardless, on a sheet that is known to be protected. The User Model only includes UnprotectWorkbook, not sheet or record.

Can anyone help? Thank you!
  • Theresa

New Post: UnprotectWorkbook() yields index out of range under multiple conditions

$
0
0
More on this:

The library is reporting that the Workbook is not write protected to begin with once queried by the code, but the individual sheets as viewed in Excel are clearly password protected. In the User Model, I do not see an UnprotectSheet or Cell, only Workbook. Can someone tell me what I am doing wrong? Thanks!

New Post: How to set currency to a cell (€) in NPOI 2.2 in XLSX

$
0
0
Hi,

The type 'Prijsex" must be a double

New Post: ICellStyle

$
0
0
Armando, I'm not sure what you are asking about the last line in your code. Can you explain a little more?

New Post: CodePlex Shutdown

$
0
0
CodePlex is shutting down, and will be frozen October of this year (2017).

Does Tony Qu or Neuzilla have any migration plans? It looks like their is a main page at https://www.nuget.org/packages/NPOI/, but all (most?) of the documentation points to https://npoi.codeplex.com as the "home" of NPOI.

Where will this discussion group move to?

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...

Viewing all 1621 articles
Browse latest View live


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