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
97
votes
8 answers

How to read file using NPOI

I found NPOI is very good to write Excel files with C#. But I want to open, read and modify Excel files in C#. How can I do this?
Akhil
  • 1,421
  • 1
  • 16
  • 21
37
votes
4 answers

MemoryStream seems be closed after NPOI workbook.write?

I am using NPOI to convert DataTable to Excel in a ASP.NET Web API project. But the I got nothing from the response. Here's my code: public HttpResponseMessage GetExcelFromDataTable(DataTable dt) { IWorkbook workbook = new XSSFWorkbook(); //…
fankt
  • 1,007
  • 1
  • 7
  • 16
29
votes
5 answers

NPOI create cell containing bold and non bold text

I'm using NPOI to output excel from Asp.Net MVC app and works very well with plain text but have now been requested to add formatting and am having problems where I need to have a single cell with bold text followed by non-bold text. e.g. This text…
Nathan
  • 931
  • 1
  • 12
  • 26
24
votes
1 answer

How to change cell color with NPOI

using NPOI.XSSF.UserModel; using NPOI.XSSF.Model; using NPOI.HSSF.UserModel; using NPOI.HSSF.Model; using NPOI.SS.UserModel; using NPOI.SS.Util; (...) XSSFWorkbook hssfwb; using (FileStream file = new FileStream(@"D:\VB\XLSX teste com…
meme
  • 597
  • 1
  • 10
  • 23
22
votes
1 answer

Trying to create a new .xlsx file using NPOI and write to it

Edit: I'm trying to write a small console application that will read in lines from an excel spreadsheet, parse the lines and write the fielded data to a new excel file. I'm using .NET and the NPOI library. I finally after much digging found Java…
Adam
  • 1,483
  • 4
  • 21
  • 50
21
votes
2 answers

How can columns be set to 'autosize' in Excel documents created with NPOI?

NPOI is a .NET port of the Java POI project, which allows one to read and write Microsoft Excel documents (as well as other Office formats). NPOI 1.2.2 has introduced support for 'autosizing' columns, whereby the column is set to the width of the…
Yellowfog
  • 2,323
  • 2
  • 20
  • 36
20
votes
2 answers

How to use NPOI to read Excel spreadsheet that contains empty cells?

When I read Excel worksheet using NPOI, empty cells are skipped. For example, it the row contains A, B, , C and I read it using IRow row = sheet.GetRow(rowNb) then row.Cells[1].ToString() will output B (as expected) but row.Cells[2].ToString()…
Yulia V
  • 3,507
  • 10
  • 31
  • 64
17
votes
11 answers

export Excel to DataTable using NPOI

I want to read Excel Tables 2010 xlsx using NPOI and then export data to DataTables but don't know how to use it. Can anyone show me step by step how to export Excel to Datatable? I have downloaded NPOI.dll, added to reference but don't know what…
Uni Le
  • 783
  • 6
  • 17
  • 30
15
votes
1 answer

Issue with writing a date to Excel file using NPOI

I am currently using NPOI to generate Excel files based on a database from my asp.net mvc app. I'm almost done with the code, except one small issue which I keep getting when when trying to write Dates to Excel. In the database (MS SQL Server) I…
AndreiC
  • 1,490
  • 4
  • 16
  • 34
15
votes
1 answer

NPOI setting different cell format

i have problem setting different format in each cell, i want to set number format to thousand separator and thousand separator with 3 decimals, when number is not integer, here is my code, i think problem look like each cell format is set by last…
Kazenga
  • 476
  • 1
  • 4
  • 15
14
votes
2 answers

How to set "AutoSize" to Excel sheet column? (NPOI)

According to How can columns be set to 'autosize' in Excel documents created with NPOI? I did so: foreach (DataColumn column in dataTable.Columns) { int rowIndex = 0; foreach (DataRow row in dataTable.Rows) { HSSFRow dataRow =…
DmitryB
  • 1,149
  • 5
  • 20
  • 34
14
votes
1 answer

npoi vertical alignment center

I've tried a dozen ways to do this and nothing works. I try to apply vertical alignment to center. Nothing seems to be working. I'd really appreciate some help. Here is my code: var workbook = new HSSFWorkbook(); var sheet =…
cah1r
  • 1,751
  • 6
  • 28
  • 47
13
votes
3 answers

How to get the value of cell containing a date and keep the original formatting using NPOI

I have an Excel file that I edited using DevExpress and I am reading using NPOI. When I try to get the value of a date cell as string, it does not keep the original value. For example: In a DevExpress grid I set this value: 2016-08-12. I want to…
Mochoa
  • 153
  • 1
  • 1
  • 7
13
votes
2 answers

how to save xls file as xlsx file using NPOI c#?

I'm using NPOI to open XLS file, then add some modifications to the XLS file. at the end i want to save it as XLSX file. i'm using this code to save it as XLS file: using (var fs = new FileStream(Name,…
Yacino
  • 645
  • 2
  • 10
  • 32
12
votes
1 answer

What is the common knowledge about NPOI, EPPlus and Koogra as of 2015?

Yes, Koogra only reads. EPPlus only supports .xlsx and is buggy in edge cases. What else should one know for choosing between them? Is one of them much slower than others? NPOI seems way to complicated and is a Java port, so is it…
Mikhail Orlov
  • 2,789
  • 2
  • 28
  • 38
1
2 3
40 41