简体   繁体   English

C#关于SpreadsheetLight使用的几个问题

[英]C# Few issues regarding SpreadsheetLight usage

1) i am using SpreadsheetLight library and i like to know how could i set row's color red or yellow ? 1)我正在使用SpreadsheetLight库,我想知道如何设置行的颜色为红色或黄色?

2) also tell me how could i set color range wise say Range["A1:Z1"] ? 2)还告诉我如何设置颜色范围明智说Range["A1:Z1"]

3) how to apply format cell range wise ? 3)如何明智地应用格式单元格范围?

sheet.Range[DataRangeCoordinate].NumberFormat = "#,##0.000;[Red](-#,##0.000);#,##0.000";

the above code is devexpress spreadsheet related.上面的代码与 devexpress 电子表格相关。 so how to do the same when working with SpreadsheetLight ?那么在使用 SpreadsheetLight 时如何做同样的事情呢?

4) how to iterate in all cell value with in For loop ? 4) 如何在 For 循环中迭代所有单元格值?

when i am using dev express spreadsheet grid then i use below code to set back & fore color当我使用 dev express 电子表格网格时,我使用以下代码设置后退和前景色

sheet.Range["A1:Z1"].Font.Color = Color.IndianRed;
sheet.Range["A1:Z1"].Fill.BackgroundColor = Color.LightGray;
sheet.Range["A1:Z1"].Style.Font.Bold = true;

5) How to set column width for all column ? 5) 如何为所有列设置列宽?

6) How to set autofit all columns ? 6) 如何设置自动调整所有列?

7) i am getting error when i am trying to create CreateStyle my code as follows 7) 当我尝试创建CreateStyle我的代码时出现错误,如下所示

using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Spreadsheet;
using SpreadsheetLight;

SLStyle style1 = sl.CreateStyle();
style.Fill.SetPattern(PatternValues.Solid, System.Drawing.Color.IndianRed, System.Drawing.Color.LightGray);
sl.SetCellStyle(1, 0, style1);

i have installed latest version of OpenXml from Nuget.我已经从 Nuget 安装了最新版本的 OpenXml。

please help me with code sample.请帮助我提供代码示例。 thanks谢谢

Did you check the developer documentation of spreadsheetlight?您是否检查了电子表格灯的开发人员文档?

They provide an example here: http://spreadsheetlight.com/downloads/samplecode/StyleRowColumnCell.cs他们在这里提供了一个例子: http : //spreadsheetlight.com/downloads/samplecode/StyleRowColumnCell.cs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM