NPOI导出真正的电子表格,支持自定义多行表头(表头风格设置),支持多个片页面导出,效果如下
DEMO资源下载 https://download.csdn.net/download/shunlu/10749942
代码如下:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data;
using NPOI.HSSF.UserModel;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using NPOI.XSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
//using log4net;
namespace Test.Models {
/*
* 调用实例
* Dictionary<string, List<NpoiHeadCfg>> dicHeads = new Dictionary<string, List<NpoiHeadCfg>>();
DataSet ds = new DataSet();
DataTable dt1 = new DataTable("测试表格1");
ds.Tables.Add(dt1); //你的数据源 dt1 自己补充数据
List<NpoiHeadCfg> heads = new List<NpoiHeadCfg>();
heads.Add(new NpoiHeadCfg("rownumber", "行号"));
heads.Add(new NpoiHeadCfg("dateid", "日期"));
NpoiHeadCfg hc3 = new NpoiHeadCfg("", "10月1号", 20);
hc3.Childs.Add(new NpoiHeadCfg("day1_zb1", "完工总数"));
hc3.Childs.Add(new NpoiHeadCfg("day1_zb2", "回复总数"));
hc3.Childs.Add(new NpoiHeadCfg("day1_zb3", "回复率"));
//
dicHeads.Add(dt1.TableName, heads);
string fileName = "调查_" + DateTime.Now.ToString("yyyyMMdd_hhmmss") + ".xls";
//调用,从服务端下载前面加 return
NpoiExcelExport.ExporXSSFExcel(ds, dicHeads, fileName);
* */
/// <summary>
/// NPOI导出真正的电子表格,支持 自定义多行表头(表头风格设置),支持多个sheet页面导出
/// </summary>
/// <remarks>
/// 创建:shunlu 2018-10-24
/// </remarks>
public class NpoiExcelExport {
// static ILog log = LogManager.GetLogger(typeof(NpoiExcelExport));
/// <summary>
/// 导出真正的电子表格
/// </summary>
/// <param name="ds">数据源</param>
/// <param name="heads">表头设置列表</param>
/// <param name="fileName">文件名称</param>
/// <param name="downLoad">是否从网络下载 true 下载,false 不下载</param>
/// <param name="savePath">保存到本地路径(不含文件名称),savePath为空不保存本地文件</param>
/// <remarks>
/// 创建:shunlu 2018-10-24
/// </remarks>
public static dynamic ExporXSSFExcel(DataSet ds, Dictionary<string, List<NpoiHeadCfg>> heads, string fileName, bool downLoad = true, string savePath = "") {
//创建 电子表格文件
XSSFWorkbook book = new XSSFWorkbook();
try {
for (int i = 0; i < ds.Tables.Count; i++) {
// log.Debug("ExporXSSFExcel " + i + ":表名:" + ds.Tables[i].TableName);
if (heads.ContainsKey(ds.Tables[i].TableName)) {
//
var _heads = heads[ds.Tables[i].TableName];
//
CreateSheet(book, i, ds.Tables[i], _heads);
}
}
//保存文件
if (!string.IsNullOrEmpty(savePath)) {
SaveExcel(book, fileName, savePath);
}
//
// 服务端下载文件
if (downLoad) {
return DownXssfFile(book, fileName);
} else {
return null;
}
} catch (Exception ex) {
throw ex;
} finally {
book.Close();
}
}
/// <summary>
/// 创建 sheet
/// </summary>
/// <param name="book"></param>
/// <param name="index"></param>
/// <param name="dt"></param>
/// <param name="heads"></param>
/// <remarks>
/// 创建:shunlu 2018-10-24
/// </remarks>
private static void CreateSheet(XSSFWorkbook book, int index, DataTable dt, List<NpoiHeadCfg> heads) {
//创建该sheet页
ISheet sheet = book.CreateSheet(dt.TableName);
//创建 表格头部
CreadHeader(book, ref sheet, dt, heads);
//创建 表格数据
CreadDataRows(book, ref sheet, dt, heads);
}
/// <summary>
/// 创建表头,支持多行
/// </summary>
/// <param name="book"></param>
/// <param name="sheet"></param>
/// <param name="dt"></param>
/// <param name="heads"></param>
/// <remarks>
/// 创建:shunlu 2018-10-24
/// </remarks>
private static void CreadHeader(XSSFWorkbook book, ref ISheet sheet, DataTable dt, List<NpoiHeadCfg> heads) {
//创建 表格头部
if (heads != null && heads.Count > 0) {
//使用自定义表头(可以支持多行表头)
IRow headRow = sheet.CreateRow(0);//创建空行
headRow.Height = (short)(heads[0].Height * 20); //设置行高 为25
//遍历自定义列头
int maxHeadRowNum = 0;//多行最大行号
//
int newColIndex = 0;
//记录当前列最多变成几列
Dictionary<int, int[]> mgs = new Dictionary<int, int[]>();
//
for (int i = 0; i < heads.Count; i++) {
if (heads[i].Childs.Count == 0) {
#region 无子节点
ICell cell = headRow.CreateCell(newColIndex); //创建单元格
cell.SetCellValue(heads[i].FieldLable); //设置单元格内容
var style = GetCellStyle(book, heads[i]);
cell.CellStyle = style;
// 设置列宽
if (heads[i].Width > 0) {
sheet.SetColumnWidth(cell.ColumnIndex, heads[i].Width * 256);
} else {
sheet.SetColumnWidth(cell.ColumnIndex, 13 * 256);
}
//
mgs.Add(i, new int[] { newColIndex, 1 });
newColIndex += 1;
#endregion
} else {
#region 多个子节点
int rowIndex = 0;
int outRowIndex = 0;
int old_colIndex = newColIndex;
int new_colIndex = CreateHeadCell(headRow, newColIndex, rowIndex, out outRowIndex, heads[i]); // 返回最大列数
//
for (int j = old_colIndex; j < new_colIndex; j++) {
if (headRow.GetCell(j) == null) {
ICell _cell = headRow.CreateCell(j); //创建单元格
_cell.SetCellValue(heads[i].FieldLable); //设置单元格内容
var style = GetCellStyle(book, heads[i]);
_cell.CellStyle = style;
}
}
mgs.Add(i, new int[] { old_colIndex, new_colIndex - old_colIndex });
//
//合并单元格
//参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列
CellRangeAddress region1 = new CellRangeAddress(headRow.RowNum, headRow.RowNum, (short)old_colIndex, (short)new_colIndex - 1);
headRow.Sheet.AddMergedRegion(region1);
//
newColIndex = new_colIndex;
//
if (outRowIndex > maxHeadRowNum) {
maxHeadRowNum = outRowIndex;//更新多行最大行号
}
#endregion
}
}
var fullstyle = GetCellStyle(book, heads[0]);
//合并 列
#region 合并列
if (maxHeadRowNum > 0) {
foreach (var mg in mgs) {
var values = mg.Value;
int cIndex = values[0];
int cCount = values[1];
if (cCount == 1) {
for (int j = headRow.RowNum; j <= maxHeadRowNum; j++) {
ICell cell = sheet.GetRow(j).GetCell(cIndex);
if (cell == null) {
cell = sheet.GetRow(j).CreateCell(cIndex);
cell.CellStyle = fullstyle;
}
}
CellRangeAddress region1 = new CellRangeAddress(headRow.RowNum, maxHeadRowNum, (short)cIndex, (short)cIndex);
headRow.Sheet.AddMergedRegion(region1);
} else {
for (int j = maxHeadRowNum; j >= headRow.RowNum; j--) {
IRow row = sheet.GetRow(j);
ICell cell = row.GetCell(cIndex);
if (cell == null) {
for (int y = 0; y < cCount; y++) {
cell = row.CreateCell(cIndex + y);
cell.CellStyle = fullstyle;
//向上行合并
CellRangeAddress region1 = new CellRangeAddress(j - 1, maxHeadRowNum, (short)(cIndex + y), (short)(cIndex + y));
headRow.Sheet.AddMergedRegion(region1);
}
} else {
for (int y = 0; y < cCount; y++) {
cell = row.GetCell(cIndex + y);
if (cell == null) {
cell = row.CreateCell(cIndex + y);
cell.CellStyle = fullstyle;
//判断上一行是否空
for (int x = j - 1; x >= headRow.RowNum; x--) {
IRow preRow = sheet.GetRow(x);
var precell = preRow.GetCell(cIndex + y);
if (precell == null) {
var newcell = preRow.CreateCell(cIndex + y);
newcell.CellStyle = fullstyle;
} else {
//向下行合并
CellRangeAddress region1 = new CellRangeAddress(x, maxHeadRowNum, (short)(cIndex + y), (short)(cIndex + y));
headRow.Sheet.AddMergedRegion(region1);
break;
}
}
}
}
break;
}
}
}
}
}
#endregion
} else {
//使用数据源列名作表头(只支持单行表头)
IRow headRow = sheet.CreateRow(0);//创建空行
var style = GetCellStyle(book, null);
//遍历列
for (int i = 0; i < dt.Columns.Count; i++) {
ICell cell = headRow.CreateCell(i);
cell.CellStyle = style;
if (!string.IsNullOrEmpty(dt.Columns[i].Caption)) {
cell.SetCellValue(dt.Columns[i].Caption);
} else {
cell.SetCellValue(dt.Columns[i].ColumnName);
}
}
}
}
/// <summary>
/// 创建表头单元格,(支持递归调用)
/// </summary>
/// <param name="preHeadRow">上一行</param>
/// <param name="startColIndex">开始列索引</param>
/// <param name="rowIndex">行索引</param>
/// <param name="outRowIndex">输出最新行索引</param>
/// <param name="headCfg">表头配置</param>
/// <returns>返回最新的列索引</returns>
/// <remarks>
/// 创建:shunlu 2018-10-24
/// </remarks>
private static int CreateHeadCell(IRow preHeadRow, int startColIndex, int rowIndex, out int outRowIndex, NpoiHeadCfg headCfg) {
// int colCount = headCfg.Childs.Count;
int preRowIndex = rowIndex;
rowIndex += 1;
outRowIndex = rowIndex;
var sheet = preHeadRow.Sheet;
XSSFWorkbook book = (XSSFWorkbook)sheet.Workbook;
var style = GetCellStyle(book, headCfg);
//
IRow curHeadRow = null;
if (sheet.LastRowNum >= rowIndex) {
curHeadRow = sheet.GetRow(rowIndex);
} else {
curHeadRow = sheet.CreateRow(rowIndex);//创建空行
for (int i = 0; i < startColIndex; i++) {
ICell cell = curHeadRow.CreateCell(i); //创建单元格
cell.CellStyle = style;
ICell mycell = preHeadRow.GetCell(i); //获取单元格
if (mycell != null)
cell.SetCellValue(mycell.StringCellValue);//设置单元格内容
}
}
int newColIndex = startColIndex;
for (int i = 0; i < headCfg.Childs.Count; i++) {
if (headCfg.Childs[i].Childs.Count > 0) {
//Console.Write("递归调用\r\n");
//
int _outRowIndex = 0;
int old_ColIndex = newColIndex;
//
int new_ColIndex = CreateHeadCell(curHeadRow, newColIndex, rowIndex, out _outRowIndex, headCfg.Childs[i]);//递归调用
//
for (int j = old_ColIndex; j < new_ColIndex; j++) {
if (curHeadRow.GetCell(j) == null) {
ICell _cell = curHeadRow.CreateCell(j); //创建单元格
_cell.SetCellValue(headCfg.Childs[i].FieldLable); //设置单元格内容
_cell.CellStyle = style;
}
}
//合并单元格
//参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列
CellRangeAddress region1 = new CellRangeAddress(curHeadRow.RowNum, curHeadRow.RowNum, (short)old_ColIndex, (short)(new_ColIndex - 1));
sheet.AddMergedRegion(region1);
//
if (_outRowIndex > outRowIndex) {
outRowIndex = _outRowIndex;
}
newColIndex = new_ColIndex;
} else {
ICell _cell = curHeadRow.CreateCell(newColIndex); //创建单元格
_cell.SetCellValue(headCfg.Childs[i].FieldLable);//设置单元格内容
_cell.CellStyle = style;
// 设置列宽
if (headCfg.Width > 0) {
sheet.SetColumnWidth(_cell.ColumnIndex, headCfg.Width * 256);
} else {
sheet.SetColumnWidth(_cell.ColumnIndex, 13 * 256);
}
//
newColIndex += 1;
}
}
//
return newColIndex;
}
/// <summary>
/// 创建 表格数据
/// </summary>
/// <param name="book"></param>
/// <param name="sheet"></param>
/// <param name="dt">数据源</param>
/// <param name="heads">表头配置</param>
/// <remarks>
/// 创建:shunlu 2018-10-24
/// </remarks>
private static void CreadDataRows(XSSFWorkbook book, ref ISheet sheet, DataTable dt, List<NpoiHeadCfg> heads) {
//
if (dt == null || dt.Rows.Count == 0) {
return;
}
if (heads != null && heads.Count > 0) {
List<NpoiHeadCfg> curhds = new List<NpoiHeadCfg>();
//遍历所有顶层节点
for (int x = 0; x < heads.Count; x++) {
List<NpoiHeadCfg> hds = GetAllLeafNode(heads[x]);//获取所有叶子子节点
curhds.AddRange(hds);
}
//遍历所有数据行
for (int i = 0; i < dt.Rows.Count; i++) {
IRow row = sheet.CreateRow(sheet.LastRowNum + 1);//创建空行
int colIndex = 0;
//遍历所有叶子子节点
for (var y = 0; y < curhds.Count; y++) {
var colname = curhds[y].FieldName;
if (dt.Columns.Contains(colname)) {//数据源列是否含有配置列
ICell cell = row.CreateCell(colIndex);
if (dt.Rows[i][colname] != DBNull.Value) {
//所有数据类型统统 ToString()
cell.SetCellValue(dt.Rows[i][colname].ToString());
}
colIndex++;
}
}
}
} else {
//遍历行
for (int x = 0; x < dt.Rows.Count; x++) {
IRow row = sheet.CreateRow(sheet.LastRowNum + 1);//创建行
//遍历列
for (int i = 0; i < dt.Columns.Count; i++) {
var colname = dt.Columns[i].ColumnName;
ICell cell = row.CreateCell(i);
if (dt.Rows[x][i] != DBNull.Value) {
cell.SetCellValue(dt.Rows[x][i].ToString());
}
}
}
}
}
/// <summary>
/// 获取当前节点所有的叶子节点
/// </summary>
/// <param name="headcfg">配置</param>
/// <returns></returns>
/// <remarks>
/// 创建:shunlu 2018-10-28
/// </remarks>
private static List<NpoiHeadCfg> GetAllLeafNode(NpoiHeadCfg headcfg) {
List<NpoiHeadCfg> heads = new List<NpoiHeadCfg>();
if (headcfg != null) {
if (headcfg.Childs.Count > 0) {
for (int i = 0; i < headcfg.Childs.Count; i++) {
var hds = GetAllLeafNode(headcfg.Childs[i]);//递归调用
if (hds.Count > 0) {
heads.AddRange(hds);
}
}
return heads;
} else {
heads.Add(headcfg);
return heads;
}
} else {
return heads;
}
}
/// <summary>
/// 判断是否指定名称的叶子节点
/// </summary>
/// <param name="heads">配置列表</param>
/// <param name="colname">目标列名称</param>
/// <returns></returns>
/// <remarks>
/// 创建:shunlu 2018-10-26
/// </remarks>
private static bool HasTargetNode(List<NpoiHeadCfg> heads, string colname) {
if (heads != null) {
var bhav = heads.Exists(w => w.Childs.Count == 0 && w.FieldName.ToLower() == colname.ToLower()); // 只查叶子节点,忽略大小写
if (bhav) {
return bhav;
} else {
for (int i = 0; i < heads.Count; i++) {
bhav = HasTargetNode(heads[i].Childs, colname);//递归调用
if (bhav) {
return true;
}
}
return false;
}
} else {
return false;
}
}
/// <summary>
/// 设置单元格样式
/// 风格请自己按headCfg参数编写
/// </summary>
/// <param name="book"></param>
/// <param name="headCfg">表头配置</param>
/// <returns></returns>
/// <remarks>
/// 创建:shunlu 2018-10-24
/// </remarks>
private static ICellStyle GetCellStyle(XSSFWorkbook book, NpoiHeadCfg headCfg) {
ICellStyle style0 = book.CreateCellStyle();
// 2、行高
// row.Height = 30 * 20; //行高为30
// excelRow.Height = 25 * 20;
// 单元格 列宽:
//if (headCfg.Width > 0) {
// cell.Row.Sheet.SetColumnWidth(cell.ColumnIndex, headCfg.Width * 256);
//}
//三、设置居中:
//cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 居中
style0.Alignment = HorizontalAlignment.Left;
style0.VerticalAlignment = VerticalAlignment.Center;
//四、设置字体:
IFont font = book.CreateFont();
font.FontName = "黑体";//.SetFontName("黑体");
font.FontHeightInPoints = (short)11.5;//.SetFontHeightInPoints((short)16);//设置字体大小
style0.SetFont(font);//选择需要用到的字体格式
//大坑,大坑,大坑,shunlu 2018-10-10
//必须设置单元格背景色 FillForegroundColor 和 FillPattern 的值才能正确显示背景色
style0.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightCornflowerBlue.Index; //(short)1灰色 NPOI.HSSF.Util.HSSFColor.LightBlue.Index;
style0.FillPattern = FillPattern.SolidForeground; // CellStyle.SOLID_FOREGROUND
//二、设置边框:
//cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框 cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框 cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框 cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框 三、设置居中: cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 居中
style0.BorderBottom = BorderStyle.Medium;// CellStyle.SOLID_FOREGROUND
style0.BorderRight = BorderStyle.Medium;
//三、设置居中:
//cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 居中
style0.Alignment = HorizontalAlignment.Left;
style0.VerticalAlignment = VerticalAlignment.Center;
//
return style0;
}
/// <summary>
/// 保存电子表格
/// </summary>
/// <param name="book"></param>
/// <param name="fileName">文件名称</param>
/// <param name="savePath">保存物理路径(不含文件名)</param>
/// <remarks>
/// 创建:shunlu 2018-10-24
/// </remarks>
private static void SaveExcel(XSSFWorkbook book, string fileName, string savePath = "") {
string fullpath = fileName;
if (!string.IsNullOrEmpty(savePath)) {
if (!savePath.EndsWith("\\"))
savePath += "\\";
fullpath = savePath + fileName;
}
if (File.Exists(fullpath)) {
File.Delete(fullpath);
}
FileStream fsOut = new FileStream(fullpath, FileMode.Create);
book.Write(fsOut);
fsOut.Close();
fsOut.Dispose();
}
/// <summary>
/// 下载电子表格文件
/// </summary>
/// <param name="book"></param>
/// <param name="saveFileName">文件名称</param>
/// <returns></returns>
/// <remarks>
/// 创建:shunlu 2018-10-24
/// </remarks>
private static HttpResponseMessage DownXssfFile(XSSFWorkbook book, string saveFileName) {
var exportData = new NpoiMemoryStream();
HttpResponseMessage response = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
exportData.AllowClose = false;
book.Write(exportData);
exportData.Flush();
exportData.Seek(0, SeekOrigin.Begin);
exportData.AllowClose = true;
response.Content = new StreamContent(exportData);
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") {
FileName = saveFileName
};
if (response.Content.Headers.ContentDisposition.Parameters.Count > 0) {
response.Content.Headers.ContentDisposition.FileName = saveFileName;
var fn = response.Content.Headers.ContentDisposition.Parameters.ElementAt(0).Value;// = saveFileName;
}
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/ms-excel");
response.StatusCode = System.Net.HttpStatusCode.OK;
return response;
}
}
/// <summary>
/// 电子表格的表头设置(支持多行表头设置)
/// </summary>
/// <remarks>
/// 创建:shunlu 2018-10-24
/// </remarks>
public class NpoiHeadCfg {
/// <summary>
/// 表头格式设置(支持多行表头)
/// </summary>
public NpoiHeadCfg() {
Childs = new List<NpoiHeadCfg>();
}
/// <summary>
/// 重载构造函数
/// </summary>
/// <param name="FieldName">数据源列名</param>
/// <param name="FieldLable">电子表格列名</param>
/// <param name="Height">行高</param>
/// <param name="Width">列宽</param>
public NpoiHeadCfg(string FieldName, string FieldLable, int Width = 10, int Height = 13) {
this.FieldName = FieldName;
this.FieldLable = FieldLable;
this.Height = Height;
this.Width = Width;
this.IsBold = true;
//
Childs = new List<NpoiHeadCfg>();
}
/// <summary>
/// 字段名称
/// </summary>
public string FieldName { get; set; }
/// <summary>
/// 字段标签(表格行头标题)
/// </summary>
public string FieldLable { get; set; }
/// <summary>
/// 高度
/// </summary>
public int Height { get; set; }
/// <summary>
/// 宽度
/// </summary>
public int Width { get; set; }
/// <summary>
/// 背景颜色
/// </summary>
public string BackColor { get; set; }
/// <summary>
/// 文本颜色
/// </summary>
public string FontColor { get; set; }
/// <summary>
/// 是否粗体显示
/// </summary>
public bool IsBold { get; set; }
/// <summary>
/// 子节点
/// </summary>
public List<NpoiHeadCfg> Childs { get; set; }
}
/// <summary>
/// 内存字节流
/// </summary>
public class NpoiMemoryStream : MemoryStream {
/// <summary>
///
/// </summary>
public NpoiMemoryStream() {
AllowClose = true;
}
/// <summary>
///
/// </summary>
public bool AllowClose { get; set; }
/// <summary>
///
/// </summary>
public override void Close() {
if (AllowClose)
base.Close();
}
}
}
文章浏览阅读1.1k次,点赞22次,收藏23次。本文通过在SSD移动硬盘中安装win10和macos双系统,实现操作系统随身携带小慢哥的原创文章,欢迎转载目录 目标 准备工作 Step1. 清空分区,转换为GPT Step2. 安装win10 Step3. 压缩win10分区容量 Step4. 创建2个分区 Step5. 将bootcamp驱动放置到exFAT分区中 Step6. 将macos分区..._mac移动硬盘装双机系统
文章浏览阅读14次。theme: cyanosishighlight: a11y-dark前言自从上次TransmittableThreadLocal框架作者评论我之后,我重新去看了下源码,终于在这个周天,我才把TransmittableThreadLocal解决线程池变量丢失的问题搞明白,而且发现我之前的认识有问题,久久孩子我之前是觉得,InheritableThreadLocal解决父子线...
文章浏览阅读366次。 距离上一篇《Exchange 2016部署实施案例篇-02.活动目录部署篇》博文更新已经过去快一周了,最近一直在忙项目上的事情和软考,整的真心有点身心俱疲啊,最近看了下上一篇博文不知道为什么访问量一直上不去,真心有点心寒啊。希望大家能多多提出宝贵意见,看看如何能让访问量上去。 废话就不多说了,开始今天的话题,Exchange的部署篇,我原定计划是把部署篇分上、下2个篇幅来写的,但最近发现好..._解决exchange2016部署先决条件
文章浏览阅读130次。原文:REACTIVE APPS WITH MODEL-VIEW-INTENT - PART4 - INDEPENDENT UI COMPONENTS作者:Hannes Dorfmann译者:却把清梅嗅这篇博客中,我们将针对如何 如何构建独立组件 进行探讨,我将阐述为什么在我看来 父子关系会导致坏味道的代码,以及为何这种关系是没有意义的。有这样一个问题时不时涌现在我的脑海中—— MVI...
文章浏览阅读662次。https://blog.csdn.net/qq_32466233/article/details/81075288_池化层后特征图尺寸
文章浏览阅读3.3k次。一、问题说明我是用的是官方示例中的这个饼状图。结果在应用到项目中后发现利用axios请求到的数据无法渲染到页面中去。并且其中value值已经改变。二、解决办法用$set改变value的值,并且重新绘制一遍表格。$set是全局 Vue.set 的别名。$set用法:向响应式对象中添加一个属性,并确保这个新属性同样是响应式的,且触发视图更新。它必须用于向响应式对象上添加新属性,因为..._vue echart初始化渲染过后无法重新渲染
文章浏览阅读3.7k次。今天在用Dev-C++ 的时候遇到一个错误“to_string is not a member of std” error解决方法:设置编译语言为ISO C++11 在菜单栏的Tool -> Compiler Option_devc++ [error] 'to_string' is not a member of 'std
文章浏览阅读1.1k次。Python 非常易学,强大的编程语言。Python 包括高效高级的数据结构,提供简单且高效的面向对象编程。Python 的学习过程少不了 IDE 或者代码编辑器,或者集成的开发编辑器(IDE)。这些 Python 开发工具帮助开发者加快使用 Python 开发的速度,提高效率。高效的代码编辑器或者 IDE 应该会提供插件,工具等能帮助开发者高效开发的特性。这篇文章收集了一些对开发者非常有_pydea兼容的
文章浏览阅读287次。一、makestrans()格式: str.maketrans(intab,outtab);功能:用于创建字符映射的转换表,对于接受两个参数的最简单的调用方式,第一个参数是字符串,表示需要转换的字符,第二个参数也是字符串表示转换的目标。注:两个字符串的长度必须相同,为一一对应的关系。注:Python3.6中已经没有string.maketrans()了,取而代之的是内建函数:bytearray...._python maketrance
文章浏览阅读5.7k次,点赞9次,收藏14次。set集合的简介,它的特点和遍历方式。介绍了HashSet重复元素存储底层原理,LinkedHashSet,TreeSet排序方法,SortedSet获取集合值的方法_set集合
文章浏览阅读3.6k次,点赞3次,收藏29次。随着城市规模的不断扩大和现代化程度的日益提高,城市排水管网越来越复杂,一些城市相继发生大雨内涝、管线泄漏爆炸、路面塌陷等事件,严重影响了人民群众生命财产安全和城市运行秩序。因此,摸清排水管网设施资产家底、建立排水管网地理信息系统,用现代化的技术手段对排水系统进行科学管理显得迫在眉睫。以时空信息为基础,充分利用感知监测网、物联网、云计算、移动互联网、工业控制和水力模型等新一代信息技术,全方位感..._污水处理智慧管理系统案列
文章浏览阅读5.7k次,点赞4次,收藏13次。上篇在详解FAT32文件系统中介绍了FAT32文件系统存储数据的原理,这篇就来介绍下NTFS文件系统。NTFS、用过Windows系统的人都知道,它是一个很强大的文件系统,支持的功能很多,存储的原理也很复杂。目前绝大多数Windows用户都是使用NTFS文件系统,它主要以安全性和稳定性而闻名,下面是它的一些主要特点。安全性高:NTFS支持基于文件或目录的ACL,并且支持加密文件系统(E_ntfs文件系统中,磁盘上的所有数据包括源文件都是以什么的形式存储