matlab 数据写入EXCLE

xlswrite

Write Microsoft Excel spreadsheet file.


Syntax

xlswrite(filename,A)
xlswrite(filename,A,sheet)
xlswrite(filename,A,xlRange)
xlswrite(filename,A,sheet,xlRange)

Input Arguments
filename — Name of file to write
string
Name of file to write, specified as a string.

If filename does not exist, xlswrite creates a file, determining the format based on the specified extension. To create a file compatible with Excel 97-2003 software, specify an extension of .xls. To create files in Excel 2007 formats, specify an extension of .xlsx, .xlsb, or .xlsm. If you do not specify an extension, xlswrite uses the default, .xls.

Example: ‘myFile.xlsx’


A — Data to write
matrix | cell array
Data to write, specified as a two-dimensional numeric or character array, or, if each cell contains a single element, a cell array.

If A is a cell array containing something other than a scalar numeric or a string, then xlswrite silently leaves the corresponding cell in the spreadsheet empty.

The maximum size of array A depends on the associated Excel version. For more information on Excel specifications and limits, see the Excel help.

Example: [10,2,45;-32,478,50]

Example: {92.0,’Yes’,45.9,’No’}

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | cell


sheet — Worksheet name
string | positive integer
Worksheet name, specified as one of the following:

String that contains the worksheet name. Cannot contain a colon (:). To determine the names of the sheets in a spreadsheet file, use xlsfinfo.

Positive integer that indicates the worksheet index.

If sheet does not exist, xlswrite adds a new sheet at the end of the worksheet collection. If sheet is an index larger than the number of worksheets, xlswrite appends empty sheets until the number of worksheets in the workbook equals sheet. In either case, xlswrite generates a warning indicating that it has added a new worksheet.


xlRange — Rectangular(方形) portion(部分) of the worksheet to write
string
Rectangular portion of the worksheet to write, specified as a string.

Specify xlRange using the syntax ‘C1:C2’, where C1 and C2 are two opposing corners that define the region to write. For example, ‘D2:H4’ represents the 3-by-5 rectangular region between the two corners D2 and H4 on the worksheet. The xlRange input is not case sensitive, and uses Excel A1 reference style (see Excel help). xlswrite does not recognize named ranges.

If you do not specify sheet, then xlRange must include both corners and a colon character, even for a single cell (such as ‘D2:D2’). Otherwise, xlswrite interprets the input as a worksheet name (such as ‘D2’).

If you specify sheet, then xlRange can specify only the first cell (such as ‘D2’). xlswrite writes input array A beginning at this cell.

If xlRange is larger than the size of input array A, Excel software fills the remainder of the region with #N/A. If xlRange is smaller than the size of A, then xlswrite writes only the subset that fits into xlRange to the file.


Output Arguments

expand all
status — Status of the write operation
1 | 0
Status of the write operation, returned as either 1 (true) or 0 (false). When the write operation is successful, status is 1. Otherwise, status is 0.

message — Error or warning generated during the write operation
structure array
Error or warning generated during the write operation, returned as a structure array containing two fields:

Structure memberRemark
messageText of the warning or error message, returned as a string.
identifierMessage identifier, returned as a string.

附:
向EXCLE追(wnnp)加数据

[num, text, raw] = xlsread(fileName);
[rowN, columnN]=size(raw);
%worksheet's index
sheet=1; 
xlsRange=['A',num2str(rowN+1)];
xlswrite(fileName,data,sheet,xlsRange);

转载于:https://www.cnblogs.com/laohaozi/p/8266605.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值