img2xlsx

版本 1.1.0.0 (2.0 KB) 作者: H K.Berg
img2xlsx is a function which transfers one or multiple image(s) to a new or existing xlsx-file.
1.5K 次下载
更新时间 2015/6/18

查看许可证

function addimage = img2xlsx(imagcell, varargin)
% This function adds one or multiple image(s) automatically to a new or
% existing Excel file. Firstly, this function is based on the tutorial of
% the MathWorks Support Team. see: http://tinyurl.com/imgtoxls.
% This method works via ActiveX.
%
% The following parameter has to be filled in to execute this function
% succesfully:
%
% - imagecell = a cell array with the name(s) of the image(s) e.g.
% exampleOne = {image.eps}; or examplemulti = {'image1.eps';'image2.eps'};
%
% varargin input:
%
% 1. img2xlsx(imagcell, name)
% varargin{1} = name). If you have an existing xlsx-file,
% give the the name of the xlsx-file. Default = 'myfile.xlsx' thus creating a
% new xlsx-file.
%
% 2. img2xlsx(imagcell, name, DIR)
% varargin{2} = DIR. Directory where the exising xlsx-file and/or image(s)
% is/are situated. Default = pwd
% IMPORTANT: the image(s), which has to be transfered, should be in this
% directory! Otherwise this function cannot find the image(s). See lines
% 115/116.
%
% 3. img2xlsx(imagcell, name, DIR, sheet)
% varargin{3} = sheet. Select the sheet-number in which the image(s) has to
% be transfered too. If you want to add a sheet, fill in 'Add'. Default = 1.
%
% 4. imgxlsx(imagcell, name, DIR, sheet, dimensions)
% varargin{4} = dimensions. Provide the dimensions of the image(s) in a
% matrix like [LinkToFile,... (The file to link to.)
% SaveWithDocument,... (To save the picture with the document.)
% Left,... (The position (in points) of the upper-left corner of the picture relative to the upper-left corner of the document.)
% Top,... (The position (in points) of the upper-left corner of the picture relative to the top of the document.)
% Width,... (The width of the picture, in points.)
% Height] (The height of the picture, in points.)
% Default = [0,1,1,1,450,352]
% see: https://msdn.microsoft.com/en-us/library/bb209605(v=office.12).aspx
%
% Version 1.0 06/13/2015 © H.K.Berg 2015
%--------------------------------------------------------------------------
% Versions 1.1 06/18/2015 © H.K.Berg 2015
%
% If you want to change one variable in varargin and the rest stay as
% default, you can leave these varaible empty by [];
%
% e.g. img2xlsx(imagcell, [],[],[], [0,1,1,1,900,704])
% -------------------------------------------------------------------------
% If this function errors somewhere and you re-run it, a common error will
% be: READ-ONLY ERROR excel: (e.g. with existing xlsx-file: 'Test.xlsx'
% in directory 'di')
%
% img2xlsx(cell, 'Test.xlsx',di)
% Error using Interface.Microsoft_Excel_14.0_Object_Library._Workbook/SaveAs
% Invoke Error, Dispatch Exception:
% Source: Microsoft Excel
% Description: Cannot access read-only document 'Test.xlsx'.
% Help File: xlmain11.chm
% Help Context ID: 0
% Error in img2xlsx (line 113)
% invoke(Workbook, 'SaveAs', [DIR '\' name]);
%
% SOLUTION: End all Excel processes via the Task Manager and execute this
% function again.
% -------------------------------------------------------------------------

引用格式

H K.Berg (2024). img2xlsx (https://www.mathworks.com/matlabcentral/fileexchange/51191-img2xlsx), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2014a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Spreadsheets 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.1.0.0

% If you want to change one variable in varargin and the rest stay as
% default, you can leave these varaible empty by [];
%
% e.g. img2xlsx(imagcell, [],[],[], [0,1,1,1,900,704])

1.0.0.0