-
2021-04-18 11:06:35
matlab如何从excel表格中读取数据?
工具:matlab 2018b
1、打开matlab击主页下入数据,可以导入excel数据此将自己命名huitushuju文件导入:
2、点击打开按钮,即可将数据导入:
3、鼠标选中Varname1所有数据,右键弹出下拉菜单,选择导入所选内容,即可将数据导入matlab工作空间,同理可以将另外两个变量也导入:
4、依次将三列数据分别导入matlab空间如下,在工作空间会看到这三个变量,并知道三个变量的最大值及最小值:
5、在工作空间选中Varname1,右键弹出下拉菜单,可以对该工作变量进行重新命名,删除,绘制各种曲线等等操作
6、在此将其重新命名为X,同理将Varname2和Varname3分别命名为Y1,Y2
7、此时在命令区域,编写如下程序:
plot(X,Y1,'r-');
hold on;
plot(X,Y2,'b-.');
xlabel('时间/s');
ylabel('距离/m');
8、运行该程序,即可绘制所需要的曲线。
求助如何在matlab中调用excel表格中的数据
Matlab xlsread() 函数可以将Excel数据读入到matlab工作空然后就可以根据读入的数据。下面给出操作流程:
1Excel中输入数据,保存文件到Matlab的工作目录下,例如 test.xlsx
2、在matlab命令窗口输入以下代码:
>> data = xlsread('test.xlsx'); % 读入excel数据
>> plot(data(1,:),data(2,:)); % 以第一行为x数据,第二行为y数据作图
3、做图如下所示
在MATLAB中怎么直接利用 EXCEL表格数据
1excel中数据粘贴到xy1(只能数字)中
2、将如下代码,在matlab
clear;clc;
load xy1.txt;
x=xy1(:,1)';%第一列数据
y=xy1(:,2)';%第二列数据
R=min(min(corrcoef(x, y)));
n=length(x);
xb=mean(x);
yb=mean(y);
x2b=sum(x.^2)/n;
xyb=x*y'/n;
b=(xb*yb-xyb)/(xb^2-x2b);
a=yb-b*xb;
y1=a b.*x;
plot(x,y,'*',x,y1);%散点图和图
xlabel('横坐标 pg/ml'),ylabel('纵坐标 mmHg');
更多相关内容 -
如何用EXCEL表格制作日历.doc
2022-07-15 08:57:37如何用EXCEL表格制作日历.doc -
办公表格模板(635个Excel表格模板).zip
2019-05-18 11:13:20办公表格模板(635个Excel表格模板)Excel是我们必备的办公软件,我们常常要用它来制作一些工作报表,有的时候我们制作工作报表,EXCEL模板是用于日常工作中常用的表格,这些表格的内容和数据会有很大的差异,但是... -
用VBA语言实现Excel表格内大量数据处理
2018-12-11 09:43:45使用Excel中自带的VBA制作工具写的一个宏程序,可通过自动读取一些表格的数据来得到结果,代码是基础性的,包含变量命名循环语句函数调用等等 -
从Excel读取数据批量制作ps图片的脚本.rar
2019-05-25 13:12:05从Excel(XML)文件读取数据,批量制作标签工卡等的Photoshop脚本,完整代码,有说明文档,解压直接可用,适用于打印店、企事业单位、网店等需要制作大量工卡、仪器标签、商品标签的朋友,脚本有详细注释,可以根据... -
办公室表格制作Excel应用技巧 高级技巧
2010-12-25 20:29:03office软件Excel的应用技巧 实用的资料 -
Csharp导出到EXCEL表格多sheet与打包软件
2011-05-19 01:22:283、环境变量 4、INI 文件项 5、ODBC 驱动程序、数据源和翻译程序 6、.NET 和 Win32 程序集 7、服务 8、文件关联、MIME 类型 9、文件、文件夹、注册表项和值的访问权限 - 搜索、下载并安装运行环境 - 在模块和... -
做表必备!超实用的五个制作Excel表头的技巧,快速学起来
2021-08-03 01:41:35超实用的五个制作Excel表头的技巧,快速学起来做Excel表格的时候,需要用到的表头制作技巧,小编都帮你整理出来了,非常实用!一、制作分项表头步骤:1.输入两个标题,按“Alt+Enter”换行,然后设置单元格“左对齐...原标题:做表必备!超实用的五个制作Excel表头的技巧,快速学起来
做Excel表格的时候,需要用到的表头制作技巧,小编都帮你整理出来了,非常实用!
一、制作分项表头
步骤:1.输入两个标题,按“Alt+Enter”换行,然后设置单元格“左对齐”。
2.右键—“设置单元格格式”—边框—选择右下角的斜线—插入空格,调整好位置即可。
二、排序
利用标题进行排序,会让我们的工作效率迅速提升。
步骤:选中表格—数据—排序—设置关键词和次序。
三、对双行标题进行筛选
当有双行标题时,选中标题行设置筛选,会发现只有大标题有筛选项,怎么办呢?
此时,应该只选择第二行进行筛选设置,这样筛选项就完整了。
四、标题倾斜
步骤:选中需要倾斜的单元格—右键,设置单元格格式—对齐,调整方向。
五、打印时每页显示表头
当表格太长,打印出来后,除了第一页,其它页面都没有表头了,怎么办?
设置方法:页面布局—点击右下角的小箭头—工作表—打印标题:选择标题行。
Excel表头的技巧都在这了,快收藏起来吧!
PS:如果电脑数据丢失了,可以使用【强力数据恢复软件】进行数据恢复,找回丢失的数据哦!返回搜狐,查看更多
责任编辑:
-
python对Excel表格数据进行读取和写入
2022-04-20 11:23:131.3提起Excel表格中指定列数据; 1.4定向筛选所需数据; 1.5多表数据统计排行; 1.6多表数据合并新excel文件。 2.系统开发环境准确: Anaconda3,在conda 中,window和ubuntu中的python功能一样。 pycharm。 3...1. 功能分析
1.1加载文件夹内所有的Excel数据;
1.2 生产贡献度分析图表(以柱状图显示表格数据);
1.3提起Excel表格中指定列数据;
1.4定向筛选所需数据;
1.5多表数据统计排行;
1.6多表数据合并新excel文件。
2.系统开发环境准确:
Anaconda3,在conda 中,window和ubuntu中的python功能一样 。
pycharm。
3.安装依赖库
这些依赖包 都要装好
import os import xlrd2 #xlrd: 对Excel进行读相关操作 import xlwt #xlwt: 对Excel进行写相关操作,且只能创建一个全新的Excel然后进行写入和保存。 import numpy import matplotlib from prettytable import PrettyTable #PrettyTable 是python中的一个第三方库,可用来生成美观的ASCII格式的表格 from matplotlib import pyplot as plt
4. 主函数设计
Excel数据分析师的主函数main(),主要用于实现系统的主界面。在主函数main()中,首先调用get_files_name()函数获取文件名。
get_files_name()函数代码如下:
#导入文件 def get_files_name(): """ 用于获取文件名 :return: 返回值为文件名组成的列表 """ file_list = os.listdir('./data') return file_list
然后调用load_data()函数来读取excel文件并字典方式保存。
#保存生产excel表 def load_data(file_list): """ 用于读取指定的文件并保存至字典数据结构中 :param file_list: 需要加载的文件列表 :return: 保存了文件内容的字典 """ dictory = {} for file in file_list: # 获取表格文件 book = xlrd2.open_workbook('./data/'+file) # 获取表格中的所有sheet names = book.sheet_names() # 获取第一个sheet sheet = book.sheet_by_index(0) # 获取当前表格的行数 rows = sheet.nrows # 获取当前表格的列数 cols = sheet.ncols # 获取表头文件,即表格第一行 head = sheet.row_values(0) for row in range(rows-1): # 如果当前字典中没有该城市则创建一个 if not sheet.cell_value(row+1, 0) in dictory.keys(): dictory[sheet.cell_value(row+1, 0)] = {} for col in range(cols-1): dictory[sheet.cell_value(row+1, 0)][head[col+1]] = float(sheet.cell_value(row+1, col+1)) return dictory
接着调用menu()函数生成功能选择菜单。
menu()函数代码如下:
# 打印菜单 def menu(): print(" ----------Excel 数据分析师----------") print("{:<30}".format(" ==============功能菜单============== ")) print("{:<30}".format(" 1. 显示当前数据 ")) print("{:<30}".format(" 2. 以柱状图展示当前数据 ")) print("{:<30}".format(" 3. 提起指定列 ")) print("{:<30}".format(" 4. 定向筛选指定元素 ")) print("{:<30}".format(" 5. 数据排行 ")) print("{:<30}".format(" 6. 重新加载数据 ")) print("{:<30}".format(" 7. 保存当前数据 ")) print("{:<30}".format(" 0. 退出程序 ")) print("{:<30}".format(" ==================================== ")) print("{:<30}".format(" 说明:输入相应数字后按下回车选择指定功能 ")) print('\n')
并且应用if语句控制各个子函数的调用,从而实现对Excel文件的选择,Excel数据的加载,选择、筛选、合并、排序和统计等功能。
主函数完整代码如下:
if __name__ == "__main__": # 导入文件 files = get_files_name() data = {} print("当前data文件夹下的文件如下:") num = 1 for file in files: print(num, file) num += 1 while(1): index_str = input("请选择需要导入的文件序号(多个文件导入时用空格分开, 输入0则导入所有文件,输入多文件则自动合并):") index_list = index_str.split(' ') try: index_list.remove('') except: pass choice_file_list = [] if index_list[0] == '0': choice_file_list = files break else: try: for item in index_list: choice_file_list.append(files[int(item)-1]) except: print("输入序号有误") continue if choice_file_list: break else: print("输入序号有误") data = load_data(choice_file_list) print("导入数据成功\n") # 调用函数,打印菜单 menu() while 1: choice = input("请选择指定功能:") if choice == '0': print("\n退出程序\n") exit() elif choice == '1': print("当前功能:显示当前数据") show_data(data) input('\n按下回车返回菜单') menu() elif choice == '2': print("当前功能:以柱状图显示数据") draw_plot(data) input('\n按下回车返回菜单') menu() elif choice == '3': print("当前功能:筛选指定列") keys = list(data[list(data.keys())[0]].keys()) print("当前表格中的列如下:") num = 1 for key in keys: print(num, key) num += 1 choice_col_list = [] while (1): index_str = input("请选择需要筛选出的列序号(多列之间用空格分开,0代表所有列):") index_list = index_str.split(' ') try: index_list.remove('') except: pass choice_file_list = [] if index_list[0] == '0': choice_col_list = keys break else: try: for item in index_list: choice_col_list.append(keys[int(item) - 1]) except: print("输入序号有误") continue if choice_col_list: break else: print("输入序号有误") data = get_specified_cols(data, choice_col_list) print("筛选成功") input('\n按下回车返回菜单') menu() elif choice == '4': print("当前功能:筛选指定行") keys = list(data[list(data.keys())[0]].keys()) print("当前表格中的列如下:") num = 1 print(num, "城市") num += 1 for key in keys: print(num, key) num += 1 col = int(input("请输入需要进行筛选的数据所在的列:"))-2 if col == -1: col = '城市' else: col = keys[col] op_list = ['<', '<=', '=', '>=', '>'] print("比较操作符如下:") num = 1 for op in op_list: print(num, op) num += 1 operation = int(input("请输入比较操作符前的序号:"))-1 operation = op_list[operation] value = input("请输入需要筛选的值:") data = get_specified_data(data, operation, col, value) print("筛选成功") input('\n按下回车返回菜单') menu() elif choice == '5': print("当前功能:数据排序") keys = list(data[list(data.keys())[0]].keys()) print("当前表格中的列如下:") num = 1 for key in keys: print(num, key) #显示当前表格中的所有的列 num += 1 col = int(input("请输入需要进行排序的数据所在的列:")) - 1 col = keys[col] reverse = input("排序方式:\n1 从大到小排序\n2 从小到大排序\n") if reverse == '1': data = sort_data(data, col, True) elif reverse == '2': data = sort_data(data, col, False) else: print("输入有误") input('\n按下回车返回菜单') menu() elif choice == '6': # 导入文件 files = get_files_name() data = {} print("当前文件夹下的文件如下:") num = 1 for file in files: print(num, file) num += 1 while (1): index_str = input("请选择需要导入的文件序号(多个文件导入时用空格分开, 输入0则导入所有文件,输入多文件则自动合并):") index_list = index_str.split(' ') try: index_list.remove('') except: pass choice_file_list = [] if index_list[0] == '0': choice_file_list = files break else: try: for item in index_list: choice_file_list.append(files[int(item) - 1]) except: print("输入序号有误") continue if choice_file_list: break else: print("输入序号有误") data = load_data(choice_file_list) print("导入数据成功\n") # 打印菜单 menu() elif choice == '7': print("当前功能:保存数据") save(data) input('\n按下回车返回菜单') menu() else: print("请输入正确的数字") input('\n按下回车返回菜单') menu()
5.模块设计
5.1 加载文件夹内所有的Excel数据
show_data()函数通过PrettyTable 库(PrettyTable 库是python中的一个第三方库,可用来生成美观的ASCII格式的表格)将之前保存的字典数据生成表格。
#加载显示数据 def show_data(dictory): try: keys = list(dictory[list(dictory.keys())[0]].keys()) except: print("当前数据为空") return head = ['城市'] head.extend(keys) table = PrettyTable(head) for key in dictory.keys(): line = [key] for key_2 in keys: line.append(dictory[key][key_2]) table.add_row(line) print(table)
效果图如下:
5.2生产贡献度分析图表(以柱状图显示表格数据)
draw_plot( )函数使用了matplotlib库。通过atplotlib.rc( )来设置字体,通过plt.bar( )函数来绘制柱状图,通过plt.legend( )函数来给图添加图例。
#制作图表 def draw_plot(dictory): font = {'family': 'MicroSoft Yahei', 'weight': 'bold', 'size': 7} matplotlib.rc('font', **font) #设置中文字体 # 定义三个颜色 index = numpy.arange(len(dictory.keys())) color = [(256 / 256, 0 / 256, 0 / 256, 1), (0 / 256, 0 / 256, 256 / 256, 1), (0 / 256, 256 / 256, 0 / 256, 1), (0 / 256, 0 / 256, 0 / 256, 1)] first_key = list(dictory.keys()) first_key = first_key[0] cols = list(dictory[first_key].keys()) data = [] for i in range(len(cols)): data.append([]) for key in dictory.keys(): for col in range(len(cols)): data[col].append(dictory[key][cols[col]]) offset = -1/4 for i in range(len(cols)): plt.bar(index+offset, data[i], color=color[i], width=1 / 5) #通过bar函数可以用柱状图来表达一些变量的统计分布 offset += 1/4 plt.xticks(index, dictory.keys())#表示刻度 plt.legend(cols)#给图像加上图例 plt.show()
效果图
5.3提起Excel表格中指定列数据
get_specified_cols()函数根据用户在菜单输入的列名,通过字典的索引筛选出列名,加载指定列的所有数据。
#提起指定列 def get_specified_cols(dictory, col_name_list): """ 筛选出指定的列 :param dictory:原始字典 :param col_name_list: 需要筛选出的列名,城市名默认出现 :return: 筛选之后的字典 """ new_dict = {} for key in dictory.keys(): new_dict[key] = {} for col_name in col_name_list: new_dict[key][col_name] = dictory[key][col_name] return new_dict
效果图如下:
参考:
-
利用excel数据批量生成大量html静态页面并自动创建文件名.rar
2021-10-10 20:07:57这个是我用python开发的1个小程序,首先你在excel表格里整理好数据。表头分别是【参数1】、【参数2】、【参数3】、、一直到【参数100】,然后你的静态html页面对应的位置就放我的标志符【参数n】,其中【参数1】用于... -
使用canvas画类似excel表格
2019-01-30 11:32:18先把表格分成3个canvas来画, 因为 excel表的左边和上面都是跟随内容来移动 通过oniscroll 事件来进行联动 如果需要再进行导出excel ,可以使用JsonExportExcel插件, 如果你需要在移动某个小表格之后出现弹框,可以使用...
思路- 先把表格分成3个canvas来画, 因为 excel表的左边和上面都是跟随内容来移动
- 通过oniscroll 事件来进行联动
- 如果需要再进行导出excel ,可以使用JsonExportExcel插件,
- 如果你需要在移动某个小表格之后出现弹框,可以使用添加,或删除dom放在canvas上面 用transfrom或position 来实现
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>index_canvas</title> <link rel="stylesheet" href="./css/index_canvas.css"> </head> <body> <div class="loading"> <img src="./images/loading.gif" alt="" class="loading_core"> </div> <div class="box_far"> <div class="header"> <div class="header_refresh"> <div> <img src="./images/refresh.png" alt=""> </div> <span>刷新</span> </div> <div class="header_SG"> <!-- 精确搜索 --> <input type="text" id="search_SG"> <button id="search_SG_button">搜索SG分布</button> <button class="reset_SG" id="reset_SG">重置</button> </div> <div class="header_volumeLabel"> <!-- 模糊匹配 --> <input type="text" id="search_volumeLabel"> <button id="search_volumeLabel_button">显示卷分布</button> <button class="reset_vol" id="reset_vol">重置</button> </div> <!-- 转成excel --> <div class="toexcel"> <div>导出excel</div> </div> <div class="header_map"> <img src="./images/suoluetu.png" alt=""> <span>缩略图</span> <!-- 缩略图宽高 isshow--> <div class="map_nav"> <div class="map_nav_child"> <div class="pointer cube"></div> <canvas id="map_line" class="pointer_main"></canvas> </div> </div> </div> </div> <!-- 中间大的内容区域 --> <div class="container"> <div class="container_left"> <ul> <script type="text/html" id="infoTitle"> <% for(var i = 0;i < list.length;i++) { %> <li class="<%= list[i].name === currentTitle ? 'current' : '' %>" data-name="<%= list[i].name %>"> <%= list[i].cName %> </li> <% } %> </script> </ul> </div> <div class="container_right"> <div class="father"> <div class="col"> <ul> <li></li> <li></li> </ul> <canvas id="col"></canvas> </div> <div class="right"> <div class="row"> <canvas id="row"></canvas> </div> <div class="content "> <canvas id="canvasId"></canvas> </div> </div> </div> </div> </div> </div> </body> <script src="./libs/jquery/jquery-1.12.4.min.js"></script> <script src="./libs/art-template/template-web.js"></script> <script src="./libs/JsonExportExcel/js-export-excel.js"></script> <script src="./js/index_canvas.js"></script> </html>
CSS
html, body { height: 100%; margin: 0; padding: 0; overflow: hidden; } .box_far { height: 100%; } ul, li { list-style: none; margin: 0; padding: 0; } input, button { outline: none; } * { box-sizing: border-box; } .isshow { visibility: hidden; } .cube { -webkit-transform: translateZ(0); -moz-transform: translateZ(0); -ms-transform: translateZ(0); -o-transform: translateZ(0); transform: translateZ(0); } @keyframes rotate { from { transform: translate(-50%, -50%) rotate(0deg); } to { transform: translate(-50%, -50%) rotate(360deg); } } .loading { position: fixed; top: 0; left: 0; z-index: 999999; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.2); } .loading .loading_core { width: 70px; height: 70px; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); } .header { min-width: 1200px; height: 60px; padding: 0 50px; border-bottom: 1px solid #ccc; } .header .header_refresh { float: left; height: 100%; line-height: 60px; margin-right: 50px; cursor: pointer; } .header .header_refresh > div { position: relative; top: 6px; width: 26px; height: 26px; border-radius: 4px; display: inline-block; background-color: #879DFB; margin: 0; } .header .header_refresh > div img { width: 20px; height: 20px; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); } .header .header_SG { float: left; height: 60px; line-height: 60px; margin-right: 50px; } .header .header_SG input { margin: 0; padding: 0; width: 200px; height: 28px; border-radius: 4px; } .header .header_SG button { height: 34px; line-height: 34px; color: #fff; background-color: #879DFB; border-radius: 4px; padding: 0 20px; } .header .header_volumeLabel { float: left; height: 60px; line-height: 60px; } .header .header_volumeLabel input { margin: 0; padding: 0; width: 200px; height: 28px; border-radius: 4px; } .header .header_volumeLabel button { height: 34px; line-height: 34px; color: #fff; background-color: #879DFB; border-radius: 4px; padding: 0 20px; } .header .toexcel { float: left; height: 60px; line-height: 60px; margin-left: 10px; cursor: pointer; } .header .toexcel div { color: #879DFB; font-weight: 700; } .header .header_map { float: right; height: 100%; line-height: 60px; cursor: pointer; position: relative; } .header .header_map img { position: relative; top: 6px; } .header .header_map .map_nav { position: absolute; right: 0; top: 50px; border-radius: 12px; padding: 12px; z-index: 99999; box-shadow: 1px 1px 20px 4px #ccc; background-color: #fff; } .header .header_map .map_nav .map_nav_child { height: 384px; position: relative; } .header .header_map .map_nav .map_nav_child .pointer { width: 40px; height: 60px; border: 1px solid #fff; position: absolute; left: 0; top: 0; cursor: move; } .container { height: 90%; overflow: auto; padding-top: 10px; background-color: #F1FBFF; } .container .container_left { width: 70px; height: 100%; float: left; background-color: #F1FBFF; } .container .container_left ul { padding-left: 16px; padding-top: 26px; } .container .container_left ul li { font-size: 18px; font-weight: 600; width: 100%; padding: 8px 15px; border-radius: 12px 0 0 12px; display: inline-block; writing-mode: tb-rl; -webkit-writing-mode: tb-rl; cursor: default; color: #999999; } .container .container_left ul li.current { color: #000; background-color: #fff; box-shadow: -3px 0 15px 2px #f0f0f0; } .container .container_right { height: 100%; overflow: hidden; padding: 20px; background-color: #fff; border-radius: 12px; } .container .container_right .father { height: 100%; } .container .container_right .father .col { float: left; width: 50px; height: 100%; background-color: #E9ECF8; overflow: hidden; position: relative; } .container .container_right .father .col ul { position: absolute; left: 0; top: 0; z-index: 99; } .container .container_right .father .col ul li { width: 50px; height: 30px; border: 1px solid #ccc; background-color: #E9ECF8; } .container .container_right .father .col::-webkit-scrollbar { display: none; } .container .container_right .father .right { height: 100%; overflow: hidden; background-color: #fff; } .container .container_right .father .right .row { width: 100%; height: 60px; overflow: hidden; background-color: #E9ECF8; } .container .container_right .father .right .row::-webkit-scrollbar { display: none; } .container .container_right .father .right .content { width: 100%; overflow: auto; position: relative; } .container .container_right .father .right .content .info-box { min-width: 100px; padding: 10px; border-radius: 6px; background-color: #FFFFE1; position: absolute; box-shadow: 1px 1px 20px 2px #666; } .container .container_right .father .right .content #canvasId { position: absolute; }
首先准备一些变量
var allData = [] //所有的数据 var mainWidth = '' //主体的宽度 var mainHeight = '' //主体的高度 var lineArr = new Array(192) //一共有多少行 // 设置小格子的宽为 90 高为 30 // 同时 设置第一个的小格子的宽为50 ,高为30 var firstGridWidth = 50 var gridWidth = 90 var gridHeight = 30
渲染左边列的图
function colCanvas() { // 1.找到canvas var cas = document.getElementById('col') // 2.动态设置canvas画布的宽高 cas.width = firstGridWidth + '' // 第一个表格的宽度 (加空字符串是转字符串) cas.height = gridHeight * (lineArr.length + 2) + '' // 3.拿到canvas绘图上下文 var ctx = cas.getContext('2d') ctx.font = '18px Courier New' //文字 ctx.strokeStyle = '#CCCCCC'; // 轮廓的颜色 // 4.绘制纵着的坐标 for (var i = 0; i < lineArr.length; i++) { if (i === 0) { ctx.rect(0, 0, firstGridWidth, gridHeight) } else if (i === 1) { ctx.rect(0, 30, firstGridWidth, gridHeight) } if (i + 1 < 10) { ctx.rect(0, 60 + gridHeight * i, firstGridWidth, gridHeight) ctx.fillText('00' + (i + 1), 8, 60 + gridHeight * (i + 1) - 8) } else if (i + 1 < 100) { ctx.rect(0, 60 + gridHeight * i, firstGridWidth, gridHeight) ctx.fillText('0' + (i + 1), 8, 60 + gridHeight * (i + 1) - 8) } else { ctx.rect(0, 60 + gridHeight * i, firstGridWidth, gridHeight) ctx.fillText(i + 1, 8, 60 + gridHeight * (i + 1) - 8) } } ctx.stroke() }
渲染上面的图
function rowCanvas() { // 1.找到canvas var cas = document.getElementById('row') // 2.动态设置canvas画布的宽高 cas.width = gridWidth * tableData.length + '' // 第一个表格的宽度 + 数组的长度 cas.height = gridHeight * 2 + '' // 3.拿到canvas绘图上下文 var ctx = cas.getContext('2d') ctx.font = '18px Courier New' ctx.strokeStyle = '#CCCCCC'; // 轮廓的颜色 var length = 0 // 绘制第一行横坐标 thList.forEach(function (item, index) { ctx.rect(length, 0, gridWidth * item.len, gridHeight) ctx.fillText(item.name, length + (gridWidth * item.len / 2), gridHeight - 8) length = length + gridWidth * item.len }) // 绘制第二行横坐标 tableData.forEach(function (item, index) { ctx.rect(gridWidth * index, gridHeight, gridWidth, gridHeight) ctx.fillText(item.name, gridWidth * index + 24, gridHeight * 2 - 8) }) ctx.stroke() }
渲染中间的图
function contentCanvas() { // 1.找到canvas var cas = document.getElementById('canvasId') // 2.动态设置canvas画布的宽高 cas.width = gridWidth * tableData.length + '' // 第一个表格的宽度 + 数组的长度 cas.height = gridHeight * lineArr.length + '' // 3.拿到canvas绘图上下文 var ctx = cas.getContext('2d') ctx.font = '18px Courier New' ctx.strokeStyle = '#CCCCCC'; // 轮廓的颜色 ContentWhite(ctx) } // 全部置为白色背景 function ContentWhite(ctx) { // 行 for (var m = 0; m < tableData.length; m++) { // 列 for (var i = 0; i < lineArr.length; i++) { ctx.rect(gridWidth * m, gridHeight * i, gridWidth, gridHeight); ctx.fillStyle = '#fff'; //背景; ctx.fillRect(gridWidth * m, gridHeight * i, gridWidth, gridHeight) ctx.fillStyle = '#333' if (tableData[m].data[i]) { ctx.fillText(tableData[m].data[i].volumeLabel, gridWidth * m + 14, gridHeight * i + 22) } else { ctx.fillText('', gridWidth * m + 14, gridHeight * i - 8) } } } ctx.stroke() }
使用onscroll事件进行联动
$('.content').on('scroll', function (e) { var top = $(this).scrollTop() var left = $(this).scrollLeft() $('#col').css({ transform: 'translateY(-' + top + 'px)' }) $('#row').css({ transform: 'translateX(-' + left + 'px)' }) $('.pointer').css({ transform: 'translate(' + left / mainWidth * $('.pointer_main').width() + 'px, ' + top / mainHeight * $('.pointer_main').height() + 'px)' }) })
将canvas画的表格导出成excel(通过一个插件JsonExportExcel.js)
JsonExportExcel github地址// 执行函数之后,导出excel jsonData excel所需要的数据, sheetName 文件名, sheetHeader 上面的头部 function JsonToExcel(jsonData, fileName, sheetName, sheetHeader) { var option = {}; option.fileName = fileName; option.datas = [{ sheetData: jsonData, //数据 sheetName: sheetName, //名称 sheetHeader: sheetHeader //头 }]; var toExcel = new ExportJsonExcel(option); toExcel.saveExcel(); }
最后的效果
源码地址 -
Excel单变量求解实例操作演示
2021-06-01 20:55:42在确定Excel所在单元格的公式及该单元格目标值的情况下,求解公式中的变量值。 例:在如下表格中,已知条件为: 1.新客客单价 2.老客客单价 3.复购率(复购率=下单老客数量/下单总人数) 4.访问/下单转化率(访问/... -
『python制作excel表格』labview 怎么将电子表格中的数据写入数据库
2020-12-08 11:29:05怎么把excel的数据存入数据库里 代码怎么写EXECL表中的导入数据库并不难!1、要懂得数据识,并建有相关的可用储该数据的表...excel表格怎样导入数据库第一步:建立库据表(按照自己的Excel数据设立字段)。[sql] view p... -
excel表格中数据作图-如何利用matlab根据excel表格里面的数据画图
2021-04-19 04:13:55如何用excel表格中的数据制图方法/步骤1,在excel中输入制图表所需要的数据。2,选择数据(选择不连续的数据可以按住“ctrl”在选择就可以了。还有选择时要连表头一起选择)。3,在“插入”菜单“图表”中选择所需要的... -
各种excel表格 非常适用的文档
2013-07-28 11:36:32集成了很多的表格,完全符合企业的各种报表的制作,各种档案的建立,还有公司制度等,图表完美,很多文档还具有自动链接、自动统计等功能,免除你寻找宏及计算公式的麻烦。 -
excel表格分析正交数据-如何应用EXCEL表进行正交试验分析
2021-01-14 17:32:05如何用excel做正交实验回归分析应用方式如下:正交试验的极差分析法又称直观分析法, 极差分析法又称直观分析法,它具有计 算简单、直观形象、简单易懂等优点, 算简单、直观形象、简单易懂等优点,是正交试验结果... -
Python番外篇:写个Excel表格转Markdown表格的小程序
2021-06-11 20:44:18hello,大家好,我是wangzirui32,今天来教大家如何写一个Excel表格转Markdown表格的小程序,开始学习吧! 1. 第三方库准备 首先,安装pandas: pip install pandas 再安装openpyxl: pip install openpyxl 没有... -
matlab 绘制excel表格数据处理-如何将excel表格中大量数据导入matlab中并作图
2021-04-26 15:56:02如何将excel表格中大量数据导入matlab中并作图将待导入的矩阵结构的数据录入Excel中,录入时注意行列要跟原矩阵一一对应录入完以后保存数据,为了后续步骤使用方便,命名时我们最好把它命名为我们接下来在MATLAB中要... -
#excel筛选数据#如何用excel表格中的数据制图
2021-04-19 09:12:00Excel表格作图中X轴的刻度怎么设置?图表当中的X轴刻度也就是横坐(在2003版本里面叫分类轴)的刻度。选图表X轴——右键——设置坐标轴格式——坐标轴选项:里面有若干选项,可根据需要设置(见抓图)。你说“ 没有选择... -
如何将excel表格中大量数据导入matlab中并作图:excel表格数据制图软件
2021-04-22 13:17:45将excel数据制作成漂亮图表的软件?做图表用什么软件excel本身就能将数据做成数据图表,有柱状图、折线图、饼图等常见问题,或者也可以用BDP个人版制作图表,除了常见的那些图表,还有词云、漏斗图、数据地图等比较... -
用QT读取Excel文件并将数据在界面上动态显示
2018-07-03 12:40:011、使用Qt5.6开发显示... 实现功能1:对Excel文件进行读操作,将Excel数据存入QList<QList<QVariant>> 类型的变量中,实现快速获取excel数据和对excel数据的操作 实现功能2:使用qcustomplot类将数据动态显示在界面上 -
入excel表格数据做图-如何向matlab中导入excel表格 利用表格数据做出图...
2021-04-22 10:23:42如何向matlab中导入excel表格 利用表格数据做出图...1.将待导入的矩阵结构的数据录入Excel中,录入时注意行列要跟原矩阵一一对应2.录入完以后保存数据,为了后续步骤使用方便,命名时我们最好把它命名为我们接下来在... -
VB6.0调用Excel制作任意表格
2019-12-24 15:40:42在VB中制作报表一般来讲有三种方法: 1、直接使用VB6.0中自带的Data Report 来做,这种方法有很大的局限性,对于比较规则的报表,但对于比较复杂的报表,比如说一张报表,上部分是人员的工资,下部分是人员的各日的... -
Excel图表美化—表格美化
2021-12-28 16:39:59Excel表格是用来存储数据的工具;这样的表大家应该很熟悉。也不能说有错,但是这样的表无论是用在学术论文还是用在职场报告,我觉得应该都不会有很好的效果。如果你还在用这样的表格进行输出,接下来的文章请仔细... -
excel表格打不开是什么原因_用什么Phthon, Excel也可以网抓多页表格
2020-11-14 03:01:37原标题:用什么Phthon, Excel也可以网抓多页表格最近python非常的火,动不动就秒杀excel,特别是从网上抓取数据十分吸人眼球。其实,Excel中的power query功能也可以网抓,甚至多页表格。兰色今天就带大家一起试上一... -
一个变量对应多个标量的结果(平均值加标准差),Excel作图方法(多数据作图方法)
2021-04-03 18:28:56首先问题是有一组多变量的数据: 想要作出随着不同的速度,不同组织的某参数的平均和方差, 最后结果如图,该图的方差没有进行特定值选取,只是某固定值 操作方法: 1.首先选中Speed 和Fat两列做出相应... -
pb中操作excel表格函数
2020-09-10 13:16:51Ole_object.Workbooks.add//新建一个Excel文件 Ole_object.Workbooks.Open("FileName")//打开一个已存在Excel文件 Ole_object.ActiveWorkBook.Sheets("SheetName").Select//选择文件中一个工作表 Ole_object.... -
python制作奖状,从excel表格中导出数据,取前20名,做成png奖状,再放入ppt中
2021-05-24 19:35:11一,从excel表格中提取所有学生姓名,班级,成绩数据 二,按要求筛选学生名单,优秀学生选成绩前20名,如有并列,也制作奖状;进步奖学生取进步率前20名,如有并列,也制作奖状,进步率为:(本周成绩-上周成绩)/... -
各种EXCEL表格模板
2010-10-09 09:03:27包含:财务管理模板、企业素材模板、人力资源模板、市场营销模板 -
表格制作学习
2013-06-09 19:15:23表格制作学习。对于办公室文员来说是很有用处的,所以你们觉得有用就看看吧 亲。就是下个文件 好麻烦