# NPOI

## C#產EXCEL

要去 using NPOI;

如果只是要格式為文字的內容，可以用某種 TABLE TR TD 去產生。

但如果要通用格式，就只能用NPOI了。NPOI有產生EXCEL的各種方法，和屬性設定。

參考資料:(<https://dotblogs.com.tw/joysdw12/2013/01/14/87228>)

## NPOI的各種類型

\--引用自參考資料

1.前言: NPOI是Apache License 2.0的開放原始碼函式庫，提供.NET程式開發人員在無安裝Microsoft Office的環境下，讀取和操作Office 97-2007文件。

2.說明: POI是支援JAVA的函式庫，而NPOI是支援.NET的開放原始碼，用以讀取xls, doc, ppt等檔案，在無安裝Microsoft Office的伺服器或是個人電腦上，可提供操作Office文件。 NPOI的特點: 開放的原始碼函式庫。 涵蓋大部分的Excel功能。 支援Office 97-2007的格式，例如xls, xlsx, docx。 支援輸出與輸入的功能。 支援.NET 4.0。 豐富的範例說明。

HSSF － 提供讀寫Microsoft Excel XLS格式檔案的功能。 XSSF － 提供讀寫Microsoft Excel OOXML XLSX格式檔案的功能。 HWPF － 提供讀寫Microsoft Word DOC格式檔案的功能。 HSLF － 提供讀寫Microsoft PowerPoint格式檔案的功能。 HDGF － 提供讀Microsoft Visio格式檔案的功能。 HPBF － 提供讀Microsoft Publisher格式檔案的功能。 HSMF － 提供讀Microsoft Outlook格式檔案的功能。

參考資料:(<http://einboch.pixnet.net/blog/post/274497938-%E4%BD%BF%E7%94%A8npoi%E7%94%A2%E7%94%9Fexcel%E6%AA%94%E6%A1%88>)

## NPOI的官網範例(簡易)

參考資料:(<https://www.leniel.net/2014/02/npoi2.0-excel-2007-xssfworkbook-and-word-2007-xwpfdocument-support.html>)

## 在本機端產生檔案

```
FileStream sw = File.Create("test.xlsx");
workbook.write(sw);
sw.Close();
```

## 範例(較多屬性)

\[NPOI]以ASP .NET配上NPOI 2.2.1產生xlsx檔(<https://dotblogs.com.tw/alenwu_coding_blog/2017/06/06/apsnet_npoi_1>)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://brianwu.gitbook.io/brian/brians-za-ji/za-ji/npoi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
