What's happening when you pass "0001" into a spreadsheet is the same thing that would happen if you typed that number into the spreadsheet from the Excel application. It converts the internal storage to "number". If you want to preserve exact text, add a single quote mark before the text, e.g. "'0001". (or {'''0001'} for cells.) This is the same thing you'd need to do if you tried tying the number into the Excel application to preserve the leading zeros.
This only happens on Windows when communicating with an active Excel process. If you're in the most recent release, you can also use the "UseExcel",false parameter, which won't do any post processing to the text; it is stored as-is. If you do, however, opening the file in Excel and re-saving might modify the contents.
1 Comment
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/444357-how-can-i-export-a-numeric-vector-that-starts-from-0-eg-0001-from-matlab-to-excel#comment_670025
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/444357-how-can-i-export-a-numeric-vector-that-starts-from-0-eg-0001-from-matlab-to-excel#comment_670025
Sign in to comment.