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

Closed Unassigned: Buffer overrun while writing a workbook [13159]

$
0
0
Hi,

I'm trying to write an excel using filestream
```
using (FileStream file = new FileStream(selectDest.SelectedPath + @"\Import update LHT.xls", FileMode.Create, FileAccess.Write))
{
wbImport.Write(file);
}
```
and I'm getting this error
```
An unhandled exception of type 'NPOI.Util.RuntimeException' occurred in NPOI.dll

Additional information: Buffer overrun i=111;endIndex=152;writeIndex=43
```

The workbook has only one sheet with about 500 rows so I don't think the size is the problem.

The workbook writing worked until last week and since I keep getting this error and I don't know why.

New Post: Landscape does not change

$
0
0
Hi,

I want to change the sheet orientation to landscape and I have set it as follow. But it does not change.

Regards,
Alex
IWorkbook wb = new XSSFWorkbook(stream);
                ISheet sheet = wb.CreateSheet("Sitrep");

                sheet.PrintSetup.Landscape = true;
                sheet.PrintSetup.PaperSize = 9;
                sheet.PrintSetup.Landscape = true;
                sheet.PrintSetup.FitHeight = 0;
                sheet.PrintSetup.FitWidth = 1;
                sheet.PrintSetup.Scale = 100;

New Post: How to change value of Excel 2003 (xls) Forms.ComboBox with NPOI 2.1.1

$
0
0
Hi,

I have a xls template file that i have to fill with data.
2 of the fields in the template are =EMBED("Forms.ComboBox.1";"").
I never really saw this on a excel file and if i try to set a value to the cell where they are (apparently this controls are not in a cell) i get a null exception.

Has anyone ever changed the value of this controls with NPOI?

NOTE: The template is protected with a passwrod and only some cells are available. I don't and i won't be able to receive the password and i can't change the template file.

Commented Unassigned: Crash when opening a file with a broken link [12727]

$
0
0
I have an .xlsx file with a cell containing "a@" - kind of a broken email address. When I try to open it using new XSSFWorkbook(file).

Exception: UrlFormatException
Invalid URI: The hostname could not be parsed.
Comments: ** Comment from web user: liver_wang **

how about this issue?
It is happening to me yestoday.
Waiting for feedback

New Post: Grouping question with NPOI

New Post: PPT

$
0
0
Is PPT support supplied anywhere? I just need to extract text, nothing else.

Thanks,

Andy

New Post: Extracting information from the Excel VBA Project part of a Workbook

$
0
0
Hi,
I am interested in extracting information from the VBA project, specifically COM references and code modules names. Is this currently possible with NPOI? If not how much effort would it be to extend NPOI to do this?
Regards

New Post: PPT

$
0
0
Hi Andy,

There is no support for ppt by NPOI. Sorry for that.

New Post: Extracting information from the Excel VBA Project part of a Workbook

$
0
0
If it's just VBA model names, I think it's possible. Please contact me via support@neuzilla.com. I can create a consulting case for you.

Created Unassigned: Variable length comment in excel file cell using NPOI [13238]

$
0
0
I want to know how to create variable length comment box using NPOI.

Code that we are using to insert comment is this:-

Comment c = drawing.createCellComment (new HSSFClientAnchor(0, 0, 0, 0, 0, 0, 6, 5));
in this case it will span the number of columns and rows mentioned in the constructor.

However if the string length inside comment box can vary for each cell and Comments should be inserted dynamically for each cell then we do not know before hand how many columns or rows the comment box should span.

Any help in this would be greatly appreciated.

Thanks
Ashwinee

New Post: I create an excel 2003 file but not display row number and column number

$
0
0
I use NPOI 2.1.1 to create an excel 2003 file. and find not display row number and column number .but the data ,style, picture is right. please fix it quickly ,thank you . if you want the excel file i can email you

New Post: How open a Workbook without Events enabled.

$
0
0
Hi all,

In Office.Interop.Excel there is a way to open a XLS file without warnings and Events:
pExcel = new Excel.ApplicationClass();
pExcel.EnableEvents = false;   
pExcel.Visible = pvisible;
pBooks = pExcel.Workbooks;
pBook = null;
pBook = pBooks.Open(pNomArchivo, pMissing, pMissing,
                pMissing, pMissing, pMissing, pMissing, pMissing, pMissing,
                pMissing, pMissing, pMissing, pMissing, pMissing, pMissing);
How can i do the same with NPOI?

Thanks in advance...

New Post: How open a Workbook without Events enabled.

$
0
0
NPOI don't use Office.Interop. It's pure .NET code. No warning or events at all.

New Post: How open a Workbook without Events enabled.

$
0
0
Ok,, so how can u open a XLSM (macros) excel file without warnings ???

Commented Unassigned: NPOI 2.1.1 HSSF SetDefaultColumnStyle changes cell color styles in whole sheet [13138]

$
0
0
Hello.
I'm new to NPOI and if I misunderstand something please correct me. I want to write a test application which opens an existing Excel Workbook (created by Excel 2007 or 2010 in 97-2003 xls Format) and removes the column style of column index 4. The first sheet in the Workbook includes several columns formatted in different value formats like Date and Text and different cell colors.
The only function I've found to set a column style was SetDefaultColumnStyle of ISheet.
Here is the code:
```
IWorkbook wb;
ISheet ws;
using (FileStream file = new FileStream(@"..\..\..\Test\Test_Table.xls", FileMode.Open, FileAccess.Read))
{
wb = new HSSFWorkbook(file);
}
ws = wb.GetSheetAt(0);
ws.SetDefaultColumnStyle(4, wb.CreateCellStyle());

using (FileStream file = new FileStream(@"..\..\..\Test\Test_Table_result.xls", FileMode.Create, FileAccess.Write))
{
wb.Write(file);
}
```
For the column E the call of SetDefaultColumnStyle works as expected. But the Colors of the cells in the other columns change. When I compare the original file with the file created by NPOI some of the cell colors are changed.
The description of SetDefaultColumnStyle says "Sets the default column style for a given column. POI will only apply this style to new cells Added to the sheet.". So this function should have no influence on any cell which already has its own cell style, didn't it? From my Point of view is a bug.
To proof that the color change is not a General Problem I also opened the workbook and saved it without changes. The resulting file is smaller than the original Excel file but the content and the formatting keeps the same. So, the Color change of the cells must have something to do with the call to SetDefaultColumnStyle.
It would be great if someone could tell me if there is another possibility to remove the default column style from a column, which does not affect the existing cell styles of the sheet. Furthermore, I hope that this behavior can be fixed in the next stable release of NPOI.
My testing workbook is attatched.

Best regards
Herbie
Comments: ** Comment from web user: Herbiee **

Hello again.
So, finally I found the root cause of this unpleasant behavior and I want to share with you my findings. It is not a bug it's a feature :).

I've read the Microsoft Specification [MS-XLS] for the XLS format and found, that Microsoft added with Excel 2007 support for more than the 56 colors.

Therefore they defined the XFExt record ([MS-XLS].pdf page 610), which can hold different format information that overwrites the settings of a XF record (each XFExt record references a specific XF record). To be backward compatible an additional record, the XFCRC record ([MS-XLS].pdf page 609), was defined.

The XFCRC record must exist exactly once, if an XLS file keeps any XFExt record. It must include the exact count of XF records in the XLS-file and a checksum over the data portion of all XF records.

When Excel loads an Excel file, it checks if an XFCRC record exists behind the last XF record. If so it checks if the XF record count and the checksum in this record match to the loaded XF records. If the XF record count or the checksum does not match, Excel knows that the last application which processed the Excel file does not support the XFExt records and that this application has done some changes to the XF records. Otherwise the count and the checksum would match. In this case Excel ignores the extended format information in any XFExt record and used the format information of the XF records.

POI and NPOI do not support those new records. So, when I call the CreateCellStyle function NPOI creates an additional XF record and adds it to the workbook. When you save this workbook to a file and open it with Excel, it shows only the colors used in the XF records (which are colors from the old standard color table), since the XFCRC record is not updated.

I've proofed this by adding the XFCRC record to NPOI and execute an update of the record before saving the workbook to a file. The resulting file still shows the correct pastel colors. If I disable the XFCRC record support, the pastel colors are replaced by similar colors of the standard color table of excel.

By the way Excel 2007 and above seem to use the XFExt record by default to set a color or other supported format information. When you set a color this color is set in the XFExt record and the most similar color of the standard color palette is set to the corresponding XF record.

Best regards
Herbiee


New Post: AutoSizeColumn got slow in NPOI 2.0

$
0
0
AutoSizeColumn is too slow, EPPlus is faster。

New Post: Worksheet protection. IsLocked=false not working

$
0
0
Hi all,

I'm new to npoi, and i'm trying to protect a worksheet while leaving certain cells open for editing. I've tried everything i can think of.

The sample below is a merger of two of the npoi tutorials

I then tried setting IsLocked = false, but the whole sheet is still protected.

Your help is greatly appreciated

I'm using NPOI v 2.1.1.0
        IWorkbook workbook = new XSSFWorkbook();
        XSSFSheet sheet1=(XSSFSheet)workbook.CreateSheet("Sheet A1");

        sheet1.CreateRow(0).CreateCell(0).SetCellValue("This is a Sample");
        int x = 1;
        for (int i = 1; i <= 15; i++)
        {
            IRow row = sheet1.CreateRow(i);
            for (int j = 0; j < 15; j++)
            {
                var cell = row.CreateCell(j);
                //cell.CellStyle.IsLocked = false;
                var unlockedstyle = workbook.CreateCellStyle();
                unlockedstyle.IsLocked = false;

                //((Range)xlWorkSheet.Cells[y + 1, x + 1]).Locked = false;
                cell.CellStyle = unlockedstyle;

                cell.SetCellValue(x++);

            }
        }

        sheet1.LockFormatRows();
        sheet1.LockFormatCells();
        sheet1.LockFormatColumns();
        sheet1.LockDeleteColumns();
        sheet1.LockDeleteRows();
        sheet1.LockInsertHyperlinks();
        sheet1.LockInsertColumns();
        sheet1.LockInsertRows();
        sheet1.ProtectSheet("password");


        FileStream sw = File.Create("test.xlsx");
        workbook.Write(sw);
        sw.Close();
I'm using NPOI v 2.1.1.0

New Post: Worksheet protection. IsLocked=false not working

$
0
0
Looks like this is a bug with v2.1.1.0
I downgraded to v2.0.6.0 (2.6) and it worked perfectly

Reviewed: NPOI 2.1.1 (9月 10, 2014)

$
0
0
Rated 4 Stars (out of 5) - in web using

Created Unassigned: [2.1.1] NPOI saves corrupted xls [13244]

$
0
0
Hello!
Open office 4.1.1 says the file made by npoi is corrupted and refuses to open it, even after repair. The file contains nothing but a sheet - no data in it. This happened after I updated to 2.1.1, it worked fine in 2.0.6 (though it corrupted xlsx files).
Corrupted xls attached.
Viewing all 1621 articles
Browse latest View live


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