IO package: Difference between revisions
Jump to navigation
Jump to search
→About read/write support
Line 30: | Line 30: | ||
==== xlswrite / odswrite versus xlsopen / odsopen ..... xlsclose / odsclose ==== | ==== xlswrite / odswrite versus xlsopen / odsopen ..... xlsclose / odsclose ==== | ||
Matlab users are used to xlsread and xlswrite, functions that can only read data from, or write data to, one sheet in a spreadsheet file at a time. For each | Matlab users are used to xlsread and xlswrite, functions that can only read data from, or write data to, one sheet in a spreadsheet file at a time. For each operation, xlsread and xlswrite first have to read the entire spreadsheet file, for write operations xlswrite also has to finally write it out completely to disk. | ||
There are faster ways, but then you'll have to dive into ActiveX/COM/VisualBasic programming. | |||
If you want to move multiple pieces of data to/from a spreadsheet file, the io package offers a much more versatile scheme: | If you want to move multiple pieces of data to/from a spreadsheet file, the io package offers a much more versatile scheme: | ||
* First open the spreadsheet file using xlsopen (for Excel or gnumeric files) | * First open the spreadsheet file using xlsopen (for Excel or gnumeric files) or odsopen (.ods or .gnumeric). | ||
'''NOTE''': the output of these functions is a file pointer handle that you should treat carefully! | '''NOTE''': the output of these functions is a file pointer handle that you should treat carefully! | ||
* (for reading data) Read the data using raw_data = xls2oct (fileptr [,sheet#] [,cellrange] [,options]) | * (for reading data) Read the data using raw_data = xls2oct (fileptr [,sheet#] [,cellrange] [,options]) |