Questions tagged [npoi]

.NET version of the Apache POI (Java) project

This project is the .NET version of the Apache POI project (the Java API for Microsoft Documents). POI is an open source project which can help you read/write xls, doc, and ppt files, so it has wide applications. For example, you can use it to generate an Excel report without Microsoft Office suite installed on your server and it is more efficient than calling Microsoft Excel ActiveX in the background; you can also use it to extract text from Office documents to help you implement full-text indexing feature (most of time this feature is used to create search engines).

Latest stable version: 2.6.0 / 17 November 2022

Latest actual source code: https://github.com/nissl-lab/npoi

612 questions
7
votes
1 answer

NPOI - How to distinguish datetime-formatted numeric Excel-cells (c#)

Background I have an Excel-file (xlxs) with a number of datetime and decimals that I want to convert into a two-dimensional string-array. The strings in the array should look exactly as the user has entered them into the excel. To do this I'm using…
user1531921
  • 1,372
  • 4
  • 18
  • 36
7
votes
1 answer

NPOI DataFormat

I'm exporting a grid with NPOI v1.2.3, and am having trouble getting cell formatting to work. I have a class that exports a list of objects to an XLS file. A row is created for each object, and a cell is added for each configured property. The…
MikeWyatt
  • 7,842
  • 10
  • 50
  • 71
7
votes
2 answers

Return excel file without saving it in the server inside controller

I want to return Excel file (using NPOI library) to user without the need to save the file in the server first. Here's my code : [HttpPost] [ValidateAntiForgeryToken] public ActionResult Report(SalesReportViewModel model) …
tickwave
  • 3,335
  • 6
  • 41
  • 82
7
votes
1 answer

Formula in Excel using NPOI

I am using NPOI dll for genrating excel sheet in C#. When I apply formula on some cell programmatically and export excel then in protected mode of excel sheet all the cells having formula show '0' value. but when i edit this excel all formulas work…
Tarun Mathur
  • 865
  • 1
  • 8
  • 25
7
votes
1 answer

NPOI - saving workbook created from template file

It is my 2nd time dealing with NPOI. I'm creating a workbook from a template excel file like this. string dldir = AppDomain.CurrentDomain.BaseDirectory + "Download\\excel\\"; string uldir = AppDomain.CurrentDomain.BaseDirectory +…
strike_noir
  • 4,080
  • 11
  • 57
  • 100
6
votes
2 answers

Format a Excel Cell Range as a Table using NPOI

I'm using NPOI to manipulate Excel(.xlsx) file data & format. I was wondering if there is a way to format the cell range to the table. // something like. ITable table = worksheet.FormatAsTable("A1:C4"); Have done some research on the internet but…
Rohim Chou
  • 907
  • 10
  • 16
6
votes
2 answers

EPPlus clone worksheet

I want to clone worksheet int my excel template file programatically. When Using NPOI library I can use HSSFWorkbook workbook = new HSSFWorkbook(fs, true); workbook.CloneSheet(1); I wonder is there something equivalent to that with EPPlus…
Bùi Đức Khánh
  • 3,975
  • 6
  • 27
  • 43
6
votes
2 answers

How to add a cell comment using NPOI Excel in C#?

I want to create a cell comment iusing NPOI Excel in C#. I have not find any clear document of that. I wrote something by myself as below. NPOI.HSSF.Record.NoteRecord nr = new NPOI.HSSF.Record.NoteRecord(); nr.Author = "Some…
aanilapaydin
  • 65
  • 3
  • 7
6
votes
4 answers

Problematic corruption of .xlsx files with NPOI - Excel cannot open the file 'file.xlsx" because the file format or file extension is not valid

When reading or modifying some user-created .xlsx files, I get the following error message: We found a problem with some content in 'test.xlsx'. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click…
justiceorjustus
  • 2,017
  • 1
  • 19
  • 42
6
votes
1 answer

NPOI formats all cells the same way

Please, take a look at the following code snippet. I simply open the excel file myfile.xlsx and I add rows from an object of type List (where my Account object only has Date, Account and Amount properties), and store the file with the name…
edd
  • 933
  • 2
  • 11
  • 24
6
votes
2 answers

NPOI Real World Pivot Example

I searched a lot, but i ended up here asking this question. There is no satisfying answer to my question: I want to create an excel pivot (WorkSheet1 as PivotTable, WorkSheet2 as Data Source) I don't have any problem with creating DataSource from…
efaruk
  • 882
  • 9
  • 25
6
votes
2 answers

NPOI WrapText isn't working?

I am trying to create a column with WrapText set to true for an XLSX file using NPOI. The following does not seem to work: var workbook = new XSSFWorkbook(); var headerRow = sheet.CreateRow(0); var cellType =…
Timothy Dooling
  • 470
  • 1
  • 4
  • 17
6
votes
1 answer

Read XLS with Protected Book and Sheet via HSSF.EventUserModel

END GOAL: Efficiently (in one pass) read all CellRecords on a huge (30,000+ row), protected Worksheet. Problem: Using the HSSF.EventUserModel, how can I read all Records (including CellRecords) for an XLS file with both Workbook and Worksheet…
Steven
  • 13,501
  • 27
  • 102
  • 146
5
votes
3 answers

C# create/modify/read .xlsx files

I am looking for a way to create, modify, read .xlsx files in C# without installing Excel or creating files on the server before giving to the user to download. I found NPOI http://npoi.codeplex.com/ which looks great but supports .xls not .xlsx I…
Baxter
  • 5,633
  • 24
  • 69
  • 105
5
votes
2 answers

NPOI C# set columns to fit on one page

I am using NPOI Version 2.5.3 in my C# application and am trying to set the scaling option (Fit All Columns on 1 Page). Which seems easy enough to do from these questions here and here. The problem: So, my problem occurs when using the code below.…
Selthien
  • 1,178
  • 9
  • 33
1 2
3
40 41