Excel 数字格式

我们可以使用 FormatString 属性来格式化任何 Excel CellRange 在 C# 中使用IronXL的显示值。

使用 workSheet["A2"] 只会选择指定地址的 Range。 要访问 Cell,可以使用 First() 方法。 但是,FormatString 属性可以直接从 CellRange 设置。 因此,通常可以省略 First() 方法。 使用与以下代码示例中所示相同的方法,可以应用更多 Excel 数字格式。

在这个代码示例中,我们使用 IronXL 库来操作 Excel 文件。 WorkBook.Load 方法加载现有的 Excel 文件,而 workSheet["A2"] 语法选择工作表中的特定单元格以应用格式。 然后,将 FormatString 属性设置为"0.00",以确保单元格值显示为两位小数。 最后,workbook.SaveAs 将修改后的工作簿保存到新文件中。

学习如何使用 C# 设置 Excel 单元格数据格式。

A PHP Error was encountered

Severity: Notice

Message: Undefined index: IronXl.Excel

Filename: helpers/counter_helper.php

Line Number: 85

Backtrace:

File: /var/www/ironpdf.com/application/helpers/counter_helper.php
Line: 85
Function: _error_handler

File: /var/www/ironpdf.com/application/views/main/sections/ready_to_started_202509.php
Line: 12
Function: getTotalDonwloadNumber

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 489
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Examples.php
Line: 44
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined index: IronXl.Excel

Filename: helpers/counter_helper.php

Line Number: 85

Backtrace:

File: /var/www/ironpdf.com/application/helpers/counter_helper.php
Line: 85
Function: _error_handler

File: /var/www/ironpdf.com/application/views/main/sections/ready_to_started_202509.php
Line: 19
Function: getTotalDonwloadNumber

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 489
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Examples.php
Line: 44
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

准备开始了吗?
Nuget 下载 1,890,100 | 版本: 2026.3 刚刚发布

A PHP Error was encountered

Severity: Notice

Message: Undefined index: IronXl.Excel

Filename: helpers/counter_helper.php

Line Number: 85

Backtrace:

File: /var/www/ironpdf.com/application/helpers/counter_helper.php
Line: 85
Function: _error_handler

File: /var/www/ironpdf.com/application/views/main/sections/still_scrolling_202512.php
Line: 17
Function: getTotalDonwloadNumber

File: /var/www/ironpdf.com/application/views/products/examples/index.php
Line: 270
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Examples.php
Line: 44
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined index: IronXl.Excel

Filename: helpers/counter_helper.php

Line Number: 85

Backtrace:

File: /var/www/ironpdf.com/application/helpers/counter_helper.php
Line: 85
Function: _error_handler

File: /var/www/ironpdf.com/application/views/main/sections/still_scrolling_202512.php
Line: 24
Function: getTotalDonwloadNumber

File: /var/www/ironpdf.com/application/views/products/examples/index.php
Line: 270
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Examples.php
Line: 44
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

Still Scrolling Icon

还在滚动吗?

想快速获得证据? PM > Install-Package IronXl.Excel
运行示例 观看您的数据变成电子表格。