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

New Post: Howto GUIDE to add NPOI

$
0
0
Hello all.

Im using NPOI 1.2.3 with Visual Studio 2008
and 3.5 NET framework
and it works with xls files.

But does not recognice xlsm files:

"The supplied data appears to be in the Office 2007+ XML. POI only supports OLE2 Office documents"

I downloaded NPOI 2.1.1 but cannot add it to my project.

https://www.dropbox.com/s/zds3qi7g7nb0ihp/Capturado.jpg

Helpme please....

Thanks

New Post: How to append datatable to an exist excel file?

$
0
0
I have to write a datatable into an exist excel file which is not empty, the columns of the datatable and the sheet of the file are the same, how can I do this? I tried the append mode, like this:
            FileStream file = new FileStream(FileName, FileMode.Append);
            hssfworkbook.Write(file);
but nothing happens, Is there anything wrong? Thank you.

New Post: Howto call a macro in a xlsm workbook

$
0
0
Hi all

I have a workbook with macros.

How can i open the workbook and EXECUTE a macro ?

Thans in advance.

New Post: Howto call a macro in a xlsm workbook

New Post: Error when creating instance of XSSFWorkbook in Visual C# CLR Database Project

$
0
0
Hi.

I'm creating a Excel export function for SQL server. I have the following bit of code in my Visual C# CLR Database Project...
public static void CreateExcelFile(SqlDataReader rdr, string outputFile, bool includeHeading)
{
    IWorkbook workbook;

    if (outputFile.ToLower().EndsWith(".xlsx"))
        workbook = new XSSFWorkbook();
    else
        workbook = new HSSFWorkbook();

    // Some other stuff

    Directory.CreateDirectory(Path.GetDirectoryName(outputFile));
    FileStream file = new FileStream(outputFile, FileMode.Create);
    workbook.Write(file);
    file.Close();
}
When I set the output file to something ending with .xls, it works like a charm, and I get the expected Excel result file. But when I specify the output file to something ending with .xlsx i get an exception at the "workbook = new XSSFWorkbook();" line. The exception message is empty and the stacktrace look like the following:
   at NPOI.POIXMLDocument.GetProperties()
   at NPOI.XSSF.UserModel.XSSFWorkbook.OnWorkbookCreate()
   at StoredProcedures.CreateExcelFile(SqlDataReader rdr, String outputFile, Boolean includeHeading)
   at StoredProcedures.ExportExcel(String sql, String outputFile, Boolean includeHeading)
I've tried to reproduce the problem in a console application without luck. Seems like there's something when running in the SQL Server. Anyone got any suggestions?

Best regards
/Henning

Created Unassigned: XSSFWorkbook.Write closed the stream [13197]

Created Unassigned: Weird behavior when locking cells NPOI 2.0.6 [13199]

$
0
0
I spotted a weird behavior when trying to lock some cells with NPOI. Using global cell styles I can only generate an excel sheet with all cells blocked or all cells editable. The __ProtectSheet()__ method seems to override the __IsLocked__ attribute when using global cell styles some times.
The workaround I found is defining a style for each cell, but excel has a limit on cell styles per sheet, so this is not a good way of doing this.

I've created a pastebin with the method:
* Problem: http://pastebin.com/xt9a5A8A
* Workaround http://pastebin.com/CthHNSvs

I've tried to move those lines of code up and down, protect the sheet in different moments and also set cell styles in different places of the code. I'd like to know if there is another way of doing this kind of work with NPOI or if this is a cataloged issue or something like that. Thank you.

New Post: Read XLSB

$
0
0
Hi all, i am new working with NPOI and i want to know if XLSB format is supported by this library.
and if it does, would you give me some example?

Thank you very much!!

Created Unassigned: NPOI.POIFS.Crypt doesn't exist in NuGet package [13206]

$
0
0
I am using NPOI to work with .xls files that are password protected.
According to the GitHub page (https://github.com/tonyqus/npoi/tree/master/main/POIFS), Crypt exists along with all of its files.
BUT on NuGet, where I installed the NPOI package, Crypt does not exist in the NPOI.POIFS namespace.

Is this a mistake? And if so, is it possible to have it added as soon as possible?
Thank you.

New Post: Error when building project - NPOI.SS.UserModel.FontBoldWeight' does not contain a definition for 'BOLD'

$
0
0
Hi,

Apologies but I'm new to this, I've picked up a project from a colleague that left (with no handover). I opened up his project and noticed a missing reference of NPOI. I downloaded the latest version and updated the reference, now when I try to build the project I get the following error:
NPOI.SS.UserModel.FontBoldWeight' does not contain a definition for 'BOLD'
which relates to the following code:
            IFont titleFont = _Workbook.CreateFont();
            titleFont.Boldweight = (short)FontBoldWeight.BOLD;
I know this was built previously as there is a version of the application that works. Any help would be appreciated.

New Post: Error when building project - NPOI.SS.UserModel.FontBoldWeight' does not contain a definition for 'BOLD'

$
0
0
It seems that this was just a case sensitivity issue:
titleFont.Boldweight = (short)FontBoldWeight.BOLD;
should have been:
titleFont.Boldweight = (short)FontBoldWeight.Bold;

Edited Issue: [Bug] Broken named ranges after existing file modification [13165]

$
0
0
I tried to open existing xlsx file (from excel 2007) and alter named ranges (can be specified in excel in Formulas/Name manager).

Problem is that when file is saved, all names' scope is changed to Sheet instead of whole Workbook. It breaks existing expressions.

Primary issue seems to be in CT_DefinedName class, Parse method is setting fields
ctObj.localSheetId = XmlHelper.ReadUInt(node.Attributes["localSheetId"]);
ctObj.localSheetIdFieldSpecified = node.Attributes["localSheetId"] != null;

while Write method always set localSheedId even if it was not originally present - it causes that field is set to 0 and scope is set to 1st sheet instead of workbook. There should be some check if localSheetIdFieldSpecified is set.
XmlHelper.WriteAttribute(sw, "localSheetId", this.localSheetId, true);


Btw, another bug is that expression "=SHEET_NAME!defined_name" cannot be parsed by NPOI, it fails with error that reference is expected. Expression "=defined_name" works but I cannot use it as it works with global scope names only.

Closed Unassigned: Export progress indication [13162]

$
0
0
Hello,

Is there possible to know the export progress state, in order to display a progress bar for time consuming excel export operations (large files combined with AutoFit) ?
And also is it possible to Cancel a started Excel export operation?

Currently I don't find any other way then displaying a marquee progress bar w/o a Cancel button.

Thanks,
Bogdan

New Post: Conditional Formatting Using NPOI

$
0
0
I have been trying to Format the cells with Different backgroundcolor which meet certain condition . I have made few attempts , it would be helpful there is a sample code.

Thanks in advance

Reviewed: NPOI 2.1.1 (八月 23, 2014)

$
0
0
Rated 5 Stars (out of 5) - wonderful

Created Unassigned: NPOI.HSSF.dll file missing [13220]

$
0
0
Hi,

I was wondering if someone from here could make me aware of how I can restore
a missing NPOI.HSSF.dll file in the bin folder of my project solutions.

If I need to download a new copy of it, that's fine, but I have no clue where to find it
or how to install it successfully.

I attempted to publish a web application not too long ago. And I received the following
error:

"Copying file bin\NPOI.HSSF.dll to obj\Release\AspnetCompileMerge\Source\bin\NPOI.HSSF.dll failed. Could not find file 'bin\NPOI.HSSF.dll'.

Any help with this would be greatly appreciated.
Thanks!

Commented Unassigned: NPOI.HSSF.dll file missing [13220]

$
0
0
Hi,

I was wondering if someone from here could make me aware of how I can restore
a missing NPOI.HSSF.dll file in the bin folder of my project solutions.

If I need to download a new copy of it, that's fine, but I have no clue where to find it
or how to install it successfully.

I attempted to publish a web application not too long ago. And I received the following
error:

"Copying file bin\NPOI.HSSF.dll to obj\Release\AspnetCompileMerge\Source\bin\NPOI.HSSF.dll failed. Could not find file 'bin\NPOI.HSSF.dll'.

Any help with this would be greatly appreciated.
Thanks!
Comments: ** Comment from web user: tonyqus **

There is no NPOI.HSSF.dll but NPOI.dll.

Closed Unassigned: NPOI.HSSF.dll file missing [13220]

$
0
0
Hi,

I was wondering if someone from here could make me aware of how I can restore
a missing NPOI.HSSF.dll file in the bin folder of my project solutions.

If I need to download a new copy of it, that's fine, but I have no clue where to find it
or how to install it successfully.

I attempted to publish a web application not too long ago. And I received the following
error:

"Copying file bin\NPOI.HSSF.dll to obj\Release\AspnetCompileMerge\Source\bin\NPOI.HSSF.dll failed. Could not find file 'bin\NPOI.HSSF.dll'.

Any help with this would be greatly appreciated.
Thanks!

New Post: AutoSizeColumn got slow in NPOI 2.0

$
0
0
Ok, I undertand the complexity of that operation, but given an xls file for which NPOI 2.0 takes about 10 minutes to autosize columns, Microsoft Excel accomplish the same task in less than a second (on the same machine). How can you explain that?

New Post: Word: Reading file and rewriting changes format.

$
0
0
I am trying to read a Word document, make some changes and then save it with a different name.

Even when not making any changes the "copy" document changes appearance. The reason is that the "Normal" Style gets a 10pt in Spacing after even if it is 0 in the original document.

Can anyone explain what happens here and how to fix it?

Code supplied below. NPOI version is 2.1.1 (2.0.6 gives same result)

Regards

Anders
        FileStream inputStream = new FileStream(@"D:\work\Original.docx", FileMode.Open);
        XWPFDocument doc = new XWPFDocument(inputStream);

        FileStream outputStream = new FileStream(@"D:\work\Copy.docx", FileMode.Create);
        doc.Write(outputStream);
        outputStream.Close();
Viewing all 1621 articles
Browse latest View live


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