function varargout = TableCollect(varargin)
% TABLECOLLECT MATLAB code for TableCollect.fig
% TABLECOLLECT, by itself, creates a new TABLECOLLECT or raises the existing
% singleton*.
%
% H = TABLECOLLECT returns the handle to a new TABLECOLLECT or the handle to
% the existing singleton*.
%
% TABLECOLLECT('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TABLECOLLECT.M with the given input arguments.
%
% TABLECOLLECT('Property','Value',...) creates a new TABLECOLLECT or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before TableCollect_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to TableCollect_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help TableCollect
% Last Modified by GUIDE v2.5 23-Mar-2024 14:43:32
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @TableCollect_OpeningFcn, ...
'gui_OutputFcn', @TableCollect_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before TableCollect is made visible.
function TableCollect_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to TableCollect (see VARARGIN)
% Choose default command line output for TableCollect
handles.output = hObject;
%初始化
set(handles.uitableFileShow,'Data',{});
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes TableCollect wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = TableCollect_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pbDataLoad.
function pbDataLoad_Callback(hObject, eventdata, handles)
% hObject handle to pbDataLoad (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[FileName,FilePath] = uigetfile('.xlsx','Multiselect','on');
%表格信息
MassageTable = get(handles.uitableFileShow,'Data');
[RowTable,~] = size(MassageTable);
try
FileName = cellstr(FileName);
%表格数据导入
NumFile = size(FileName,2);
for i= RowTable+1:NumFile+RowTable
MassageTable{i,1}= true;
MassageTable{i,2}= FileName{i-RowTable};
MassageTable{i,3}= FilePath;
end
set(handles.uitableFileShow,'Data',MassageTable);
catch
end
% --- Executes on button press in pbStartCollect.
function pbStartCollect_Callback(hObject, eventdata, handles)
% hObject handle to pbStartCollect (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global DataBase;
global IndexSum;
DataBase = {};
IndexSum = 1;
%文件读取
MassageTabel = get(handles.uitableFileShow,'Data');
[RowTabel,~] = size(MassageTabel);
IndexData = [];
NumFile = 0;
MaxRowTabel = 0;
for i = 1:RowTabel
if MassageTabel{i,1}
[~,~,ResultDataTemp] = xlsread([MassageTabel{i,3} MassageTabel{i,2}]);
%行列区别
if get(handles.popupmenuRowCol,'value') == 1
ResultData{i} = ResultDataTemp;
elseif get(handles.popupmenuRowCol,'Value') == 2
ResultData{i} = ResultDataTemp';
end
IndexData = [IndexData i];
NumFile = NumFile+1;
if get(handles.popupmenuRowCol,'value') == 1
[~,RowTemp] = size(ResultDataTemp);
elseif get(handles.popupmenuRowCol,'Value') == 2
[~,RowTemp] = size(ResultDataTemp');
end
if RowTemp >MaxRowTabel
MaxRowTabel = RowTemp;
end
end
end
%文件数量选择错误判定
if NumFile <2
errordlg("选中文件数量不得少于2个,请重新选择");
end
%矩阵对齐
for i = IndexData
[Row,Col] = size(ResultData{i});
Gap = MaxRowTabel - Col;
if Gap > 0
for iRow = 1:Row
for iCol = Col + 1:MaxRowTabel
ResultData{i}{iRow,iCol} = 'NaN';
end
end
end
end
%映射表生成
NumMat = {};
NumMatSum = CreatNumMat(ResultData{IndexData(1)});
for i = IndexData
NumMat{i} = CreatNumMat(ResultData{i});
NumMatSum = union(NumMatSum,NumMat{i},'rows');
end
%行列区别
if get(handles.popupmenuRowCol,'Value') ==1
NumMatSum = NumMatSum;
elseif get(handles.popupmenuRowCol,'Value') == 2
NumMatSum = NumMatSum';
end
[rows,clos] = size(NumMatSum);
%映射表反解excel表
ResCellSum = {};
for i = 1:rows
for j = 1:clos
if strcmp(DataBase{NumMatSum(i,j)},'NaN')
ResCellSum{i,j} = [];
else
ResCellSum{i,j} = DataBase{NumMatSum(i,j)};
end
end
end
%打开excel表格
try
Excel = actxGetRunningServer('Excel.Application');
catch
Excel = actxserver('Excel.Applcationy');
end
%excle表格可视化
Excel.visible = 1;
%excel加入工作表
Workbook = Excel.Workbooks.Add;
ExcelActiveWorkbooks = get(Excel,'ActiveWorkBook');
eSheet = get(ExcelActiveWorkbooks,'Sheets');
eSheet1 = Item(eSheet,1);
%构建excel列标
colStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
CellCol = {};
for i = 1:26
CellCol{i} = colStr(i);
end
for i = 1:26
for j = 1:26
CellCol{i*26+j} = [colStr(i),colStr(j)];
end
end
for i = 1:26
for j = 1:26
for k = 1:26
CellCol{i*26*26+j*26+k} = [colStr(i),colStr(j),colStr(k)];
end
end
end
if clos > 18278
errordlg('文件列数超限,列数最大值为18278!');
return
end
ExcelRangeCell =['A1',':',CellCol{clos},num2str(rows)];
eSheet1.Range(ExcelRangeCell).Value = ResCellSum;
% --- Executes on selection change in popupmenuRowCol.
function popupmenuRowCol_Callback(hObject, eventdata, handles)
% hObject handle to popupmenuRowCol (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenuRowCol contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenuRowCol
% --- Executes during object creation, after setting all properties.
function popupmenuRowCol_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenuRowCol (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor
没有合适的资源?快使用搜索试试~ 我知道了~
Matlab GUI工具-多个Excel文件合并成一个文件,且去重处理
共14个文件
xlsx:6个
m:3个
asv:2个
2 下载量 184 浏览量
2024-03-23
16:16:57
上传
评论
收藏 163KB ZIP 举报
温馨提示
GUI应用,简单的点选即可实现快速高效办公,快来摸鱼吧
资源推荐
资源详情
资源评论
收起资源包目录
表格汇总.zip (14个子文件)
表格汇总
TableCollect.fig 11KB
CreatNumMat.m 1KB
截图文件
文件.png 32KB
应用截图.png 94KB
CreatNumMat.asv 820B
表格文件
小黄.xlsx 8KB
小青.xlsx 8KB
小蓝.xlsx 8KB
小红.xlsx 9KB
小橙.xlsx 8KB
小紫和小绿.xlsx 8KB
TableCollect.asv 8KB
TableCollect.m 8KB
CheakRepetition.m 222B
共 14 条
- 1
资源评论
肖田变强不变秃
- 粉丝: 171
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功