File Exchange

image thumbnail

dat2xls

version 1.0.0.0 (3.95 KB) by Fahad Al Mahmood
Copying (ASCII) data file (including headers & column names) to XLS.

2 Downloads

Updated 13 Oct 2004

View License

This program reads a (text data file) consisting of headers, column titles and column data (see attached data.txt). Then it opens or creates existing excel file and saves data into specified sheetname.

NOTE: The program will automatically identify the number of headerlines, columns and the column names using what so called "common sense"!

dat2xls(datfile,xlsfile,sheetname)
dat2xls(datfile,xlsfile)

datfile: Name of data file.
xlsfile: Name of excel file.
sheetname: sheet name (optional, default is 'Sheet1') if specified, a sheet with the specified name must be existing.

Example:

datfile = 'data.txt';
xlsfile = 'data.xls';
sheetname = 'Sheet2';
dat2xls(datfile,xlsfile,sheetname)
%dat2xls(datfile,xlsfile) % Will write to 'Sheet1'

Cite As

Fahad Al Mahmood (2021). dat2xls (https://www.mathworks.com/matlabcentral/fileexchange/4517-dat2xls), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (4)

Ketan D

If there is no header, it gives the following error:

??? Undefined function or variable "header".

Error in ==> dat2xls at 78
for ii=length(header):-1:1

alain chuchu

bijoy p

i got this error while executing the program

Warning: Reference to uninitialized variable m in dat2xls at line 108.
> In D:\bijoy\matlab\dat2xls.m at line 108
??? Dispatch : Exception occurred.

Error in ==> \\ncc-z\matlab\6.1\toolbox\matlab\winfun\@activex\private\actxcli.dll
Error in ==> \\ncc-z\matlab\6.1\toolbox\matlab\winfun\@activex\get.m
On line 15 ==> varargout{1} = actxcli('get', varargin{1}.Handle,varargin{2:end});

Error in ==> D:\bijoy\matlab\dat2xls.m
On line 155 ==> ActivesheetRange = get(Activesheet,'Range',[FirstCol num2str(FirstRow)],[LastCol num2str(LastRow)]);

krishna proddaturi

Text files and xls files with different kinda header and then with actual data this is the one that suits the best use
A=importdata('data.xls');
B=A.data.Sheet1; later to get that acutal data removing all the header info...
This is the best I knew here

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!