当前位置: 首页 > news >正文

大连开发区规划建设局网站推广app有哪些

大连开发区规划建设局网站,推广app有哪些,莱州市建设局网站,ui设计师怎么做自己的网站Aspose.Cells是一款功能强大的Excel文档处理和转换控件,开发人员和客户电脑无需安装Microsoft Excel也能在应用程序中实现类似Excel的强大数据管理功能。 1、获取工作薄Workbook string excelFile "C:\Users\Administrator\Desktop\FE.xlsx"; Workbook …

Aspose.Cells是一款功能强大的Excel文档处理和转换控件,开发人员和客户电脑无需安装Microsoft Excel也能在应用程序中实现类似Excel的强大数据管理功能。


1、获取工作薄Workbook
string excelFile = "C:\Users\Administrator\Desktop\FE.xlsx";
Workbook wb = OpenWorkbook(excelFile);
2、获取工作表对象Worksheet
// 按序号
Worksheet sheet = wb.Worksheets[0];
// 按sheet名
Worksheet sheet = wb.Worksheets["sheet1"];
3、获取Cells、Cell
// 获取Cells
Cells cells = sheet.Cells
// 获取Cell,序号从0开始
Cell cell = cells[1,2]
4、读取、写入Cell值
// 读取cell值
var va = cell.Value;
string va = cell.StringValue;
...
// 写入cell值
cell.Value = "这是一个写入值";
cell.PutValue("写入值");
5、获取并设置单元格样式
// 获取style
Style style = cell.GetStyle();
// 数字型
style.Number = 4;
// 数字格式
style.Custom = "0.00";// 设置style
cell.SetStyle(style);

更多详细设置:

style.HorizontalAlignment = TextAlignmentType.Center;//文字居中
style.Font.Name = "宋体";//文字字体
style.Font.Size = 22;//文字大小
style.IsLocked = false;//单元格解锁
style.Font.IsBold = true;//粗体
style.ForegroundColor = Color.FromArgb(0xaa, 0xcc, 0xbb);//设置背景色
style.Pattern = BackgroundType.Solid; //设置背景样式
style.IsTextWrapped = true;//单元格内容自动换行
style.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin; //应用边界线 左边界线
style.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin; //应用边界线 右边界线
style.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin; //应用边界线 上边界线
style.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin; //应用边界线 下边界线
6、保存Workbook并释放
// 保存
wb.Save(excelFile);
wb.Dispose();
7、删除行
// 获取Cells
Cells cells = sheet.Cells
// 删除单行,序号从0开始
cells.DeleteRow(3);
// 删除多行,参数2为要删的行数
cells.DeleteRows(3,10);
8、删除列
// 获取Cells
Cells cells = sheet.Cells
// 删除列,序号从0开始
cells.DeleteColumn(3);
// 删除多列,参数2为要删的列数
cells.DeleteColumns(3,10);
9、复制行(复制列同理)
// 获取Cells
Cells cells = sheet.Cells
// 复制单行,从参数2复制到参数3
cells.CopyRow(cells, 83, 85);
// 复制多行,参数4为要复制的行数
cells.CopyRows(cells, 83, 168 + i * 85, 85);
10、强制更新计算公式、设置公式
//强制更新计算公式
wb.CalculateFormula();
//给单元格设置计算公式
cell.Formula = "=AVERAGE(B1:E1)";
11、设置行高列宽
//设置行高
cells.SetRowHeight(0, 20); 
//设置列宽
cells.SetColumnWidth(1, 30);
12、合并、取消合并单元格
// 参数:起始行,起始列,行数,列数
cells.Merge(0, 0, 1, 5);
// 参数:起始行,起始列,行数,列数
cells.UnMerge(4, 2, 2, 3);
13、插入行、列
// 在序号处插入一行
cells.InsertRow(5);
// 参数2为插入的行数
cells.InsertRows(5,3);cells.InsertColumn(5);
cells.InsertColumns(5,3);
14、将字典dict的值映射写入Excel文件
public static void ExcelAttributeMapper(string excelPath, int sheet_in_col, int sheet_map_col, Dictionary<string, string> dict, int startRow = 0)
{// 打开工作薄Workbook wb = OpenWorkbook(excelPath);// 打开工作表Worksheet sheet = wb.Worksheets[0];// 逐行处理for (int i = startRow; i <= sheet.Cells.MaxDataRow; i++){//  获取目标cellCell inCell = sheet.Cells[i, sheet_in_col];Cell mapCell = sheet.Cells[i, sheet_map_col];// 属性映射if (inCell is not null && dict.ContainsKey(inCell.StringValue)){mapCell.Value = dict[inCell.StringValue];   // 赋值}}// 保存wb.Save(excelFile);wb.Dispose();
}
15、简单的写入值
public static void ExcelWriteCell(string excelPath, int row, int col, string cell_value)
{// 打开工作薄Workbook wb = OpenWorkbook(excelPath);// 打开工作表Worksheet sheet = wb.Worksheets[0];// 获取cellCell cell = sheet.Cells[row, col];// 写入cell值cell.Value = cell_value;// 保存wb.Save(excelFile);wb.Dispose();
}
16、Excel设置单元格的格式
public static void ExcelSetColStyle(string excelPath, int col, int startRow, int styleNumber = 4, int digit = 2)
{// 打开工作薄Workbook wb = OpenWorkbook(excelPath);// 打开工作表Worksheet sheet = wb.Worksheets[0];for (int i = startRow; i <= sheet.Cells.MaxDataRow; i++){// 获取cellCell cell = sheet.Cells[i, col];// 获取styleStyle style = cell.GetStyle();// 数字型style.Number = styleNumber;// 小数位数if (digit == 1) { style.Custom = "0.0"; }else if (digit == 2) { style.Custom = "0.00"; }else if (digit == 3) { style.Custom = "0.000"; }else if (digit == 4) { style.Custom = "0.0000"; }}// 保存wb.Save(excelFile);wb.Dispose();
}
17、删除Excel表中的0值行【指定多个列】
private static List<int> ExcelDeleteNullRowResult(string excelPath, List<int> deleteCols, int startRow = 0)
{List<int> list = new List<int>();// 打开工作薄Workbook wb = OpenWorkbook(excelPath);// 打开工作表Worksheet sheet = wb.Worksheets[0];// 强制更新表内的公式单元格wb.CalculateFormula();// 找出0值行for (int i = sheet.Cells.MaxDataRow; i >= startRow; i--){// 设置一个flagbool isNull = true;// 循环查找各列的值foreach (var deleteCol in deleteCols){Cell cell = sheet.Cells.GetCell(i, deleteCol);if (cell != null)  // 值不为空{string str = cell.StringValue;if (str != "") // 值不为0{if (double.Parse(str) != 0){isNull = false;break;}}}}// 输出删除列if (isNull){list.Add(i);}}// 保存wb.Save(excelFile);wb.Dispose();// 返回值return list;
}
18、从Excel文件中获取Dictionary
public static Dictionary<string, string> GetDictFromExcel(string excelPath, int col1 = 0, int col2 = 1)
{// 定义字典Dictionary<string, string> dict = new Dictionary<string, string>();// 打开工作薄Workbook wb = OpenWorkbook(excelPath);// 打开工作表Worksheet sheet = wb.Worksheets[0];// 获取key和value值for (int i = 0; i <= sheet.Cells.MaxDataRow; i++){Cell key = sheet.Cells[i, col1];Cell value = sheet.Cells[i, col2];if (key != null && value != null){if (!dict.ContainsKey(key.StringValue)){if (key.StringValue != "" && value.StringValue != "")   // 空值不纳入{dict.Add(key.StringValue, value.StringValue);}}}}wb.Dispose();// 返回dictreturn dict;
}
http://www.hkea.cn/news/730180/

相关文章:

  • 新产品线上推广方案鞍山seo外包
  • 网站建网站建设和优佛山网络推广培训
  • 毕业设计做网站怎么样微信crm管理系统
  • 个人网站开发多少钱电脑培训班零基础
  • 互联网有哪些岗位宁波免费seo在线优化
  • 惠州做棋牌网站建设哪家技术好哪里的网络推广培训好
  • 如何做线上赌博的网站推广策略有哪些方法
  • 男的女的做那个视频网站百度收录需要多久
  • 大通县wap网站建设公司网站免费制作
  • 哪个网站教做公众号甘肃百度推广电话
  • 网站怎么让百度收录广告网络推广
  • 小型网站设计及建设论文定制网站制作公司
  • 视频网站建设费用排名优化网站seo排名
  • 怎么自己做网站服务器linux百度账号查询
  • 梧州网站推广方案百度热搜 百度指数
  • 网站不兼容ie6自助建站模板
  • 甘肃网站建设公司百中搜优化软件
  • 国内外贸网站建设公司seo教程 百度网盘
  • 一物一码二维码生成系统最好用的系统优化软件
  • 如何在大网站做外链镇江网站建站
  • 杭州网站建设公司导航短视频营销案例
  • 昆明做网站建设有哪些长尾关键词排名工具
  • 一女被多男做的视频网站网站seo系统
  • 网站建设 青海网站建设找哪家好
  • win7 网站配置优化方案官网电子版
  • 广州seo优化公司排名浙江seo博客
  • 全网推广的方式有哪些抖音seo推荐算法
  • 网站开发开源架构抖音营销软件
  • 自己做的网站能放到网上么青岛seo经理
  • 营业推广策划方案邵阳网站seo