|
| 1 | +# OpenExcelLite.Net48 |
| 2 | + |
| 3 | +A lightweight, schema-safe Excel (XLSX) generator for **.NET Framework 4.8 / 4.8.1** |
| 4 | +built on the official **OpenXML 3.3.0** SDK — with **no Excel interop**, **no COM**, and **zero dependencies**. |
| 5 | + |
| 6 | +This library mirrors the simplicity and API design philosophy of **OpenExcelLite (modern .NET)** |
| 7 | +while remaining fully compatible with legacy .NET Framework applications. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## ✨ Features |
| 12 | + |
| 13 | +- Create Excel files entirely **in memory** or **save to file** |
| 14 | +- **Multi-sheet** workbook support |
| 15 | +- **Schema-safe** rows (column count validated) |
| 16 | +- **AddRow()**, **AddRows()**, **AddEmptyRows()** |
| 17 | +- **HyperlinkCell** for clickable links |
| 18 | +- **Auto column width** calculation |
| 19 | +- **Header styling** (bold + background) |
| 20 | +- **Freeze panes** (top rows / left columns) |
| 21 | +- **Date** handling using OADate numeric format |
| 22 | +- Works on **.NET Framework 4.8 / 4.8.1** |
| 23 | +- Zero external dependencies (other than OpenXML SDK) |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## 📦 Installation |
| 28 | + |
| 29 | +### Project Reference |
| 30 | + |
| 31 | +```xml |
| 32 | +<ItemGroup> |
| 33 | + <ProjectReference Include="OpenExcelLite.Net48.csproj" /> |
| 34 | +</ItemGroup> |
| 35 | + |
| 36 | + |
| 37 | +```xml |
| 38 | +<ItemGroup> |
| 39 | + <ProjectReference Include="OpenExcelLite.Net48.csproj" /> |
| 40 | +</ItemGroup> |
| 41 | +``` |
| 42 | + |
| 43 | +Or use NuGet (if published): |
| 44 | + |
| 45 | +``` |
| 46 | +Install-Package OpenExcelLite.Net48 |
| 47 | +``` |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +## 🚀 Usage |
| 52 | + |
| 53 | +### ✔ Simple Example |
| 54 | + |
| 55 | +```csharp |
| 56 | +var workbook = new ExcelWorkbook(); |
| 57 | +var sheet = workbook.AddSheet("Users"); |
| 58 | + |
| 59 | +sheet.AddRow("Id", "Name", "Email"); |
| 60 | +sheet. AddRow( 1, "Alex", "[email protected]"); |
| 61 | +sheet. AddRow( 2, "Bella", "[email protected]"); |
| 62 | + |
| 63 | +workbook.SaveToFile("users.xlsx"); |
| 64 | +``` |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +### ✔ Hyperlink Example |
| 69 | + |
| 70 | +```csharp |
| 71 | +var wb = new ExcelWorkbook(); |
| 72 | +var sheet = wb.AddSheet("Links"); |
| 73 | + |
| 74 | +sheet.AddRow("Title", "URL"); |
| 75 | +sheet.AddRow("OpenAI", new HyperlinkCell("Visit", "https://openai.com")); |
| 76 | + |
| 77 | +wb.SaveToFile("links.xlsx"); |
| 78 | +``` |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +### ✔ Multi-Sheet Example |
| 83 | + |
| 84 | +```csharp |
| 85 | +var wb = new ExcelWorkbook(); |
| 86 | + |
| 87 | +var products = wb.AddSheet("Products"); |
| 88 | +products.AddRow("Id", "Name", "Price"); |
| 89 | +products.AddRow(1, "Keyboard", 129.90m); |
| 90 | + |
| 91 | +var orders = wb.AddSheet("Orders"); |
| 92 | +orders.AddRow("OrderId", "Total"); |
| 93 | +orders.AddRow(1001, 199.80m); |
| 94 | + |
| 95 | +wb.SaveToFile("multi_sheet.xlsx"); |
| 96 | +``` |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +### ✔ In-Memory Array Example |
| 101 | + |
| 102 | +```csharp |
| 103 | +var wb = new ExcelWorkbook(); |
| 104 | +wb.AddSheet("Data").AddRow("A", "B", "C"); |
| 105 | + |
| 106 | +byte[] bytes = wb.ToArray(); |
| 107 | +File.WriteAllBytes("array.xlsx", bytes); |
| 108 | +``` |
| 109 | + |
| 110 | +--- |
| 111 | + |
| 112 | +## 📁 Samples |
| 113 | + |
| 114 | +See the `samples/OpenExcelLite.Net48.Sample` folder for complete demo cases: |
| 115 | + |
| 116 | +- In-memory examples |
| 117 | +- Hyperlinks |
| 118 | +- Empty rows (before or after header) |
| 119 | +- Multi-sheet |
| 120 | +- Multi-sheet hyperlinks |
| 121 | +- 10-sheet generation |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +## 🧪 Unit Tests |
| 126 | + |
| 127 | +The `tests/OpenExcelLite.Net48.Tests` project includes coverage for: |
| 128 | + |
| 129 | +- Multi-sheet workbooks |
| 130 | +- Hyperlink relationships |
| 131 | +- Auto column widths |
| 132 | +- Date cells (OADate) |
| 133 | +- Freeze panes correctness |
| 134 | + |
| 135 | +--- |
| 136 | + |
| 137 | +## 🔧 Compatibility |
| 138 | + |
| 139 | +| Feature | Supported | |
| 140 | +|--------|-----------| |
| 141 | +| .NET Framework 4.8 / 4.8.1 | ✔ | |
| 142 | +| C# 7.3 | ✔ | |
| 143 | +| OpenXML 3.3.0 | ✔ | |
| 144 | +| Streaming APIs (Span/ArrayPool) | ✖ Not supported on .NET48 | |
| 145 | +| Async APIs | ✖ | |
| 146 | + |
| 147 | +--- |
| 148 | + |
| 149 | +## 📄 License |
| 150 | + |
| 151 | +This project is released under the **MIT License**. |
| 152 | + |
| 153 | +See: `LICENSE` |
| 154 | + |
0 commit comments