Code to automatically generate filename from reading cell in an excel file
조회 수: 9 (최근 30일)
이전 댓글 표시
Hello, its been a while since I used MATLAB and I seem to be having problems.
What Im trying to do: To read an excel file (specific cells) > name file using a series of those cells.
ie cell 1 = C2, cell 2 = 2013_02_25, cell 3 = WE08GYD >> file saved as C2_2013_02_25_WE08GYD.pdf
The code i'm using:
[~,~,testcll] = xlsread('Book1.xlsx','Sheet2','A1'); % 'C2';
[~,~,testdate] = xlsread('Book1.xlsx','Sheet2','A2'); %'2013_07_07';
[~,~,testnumber] = xlsread('Book1.xlsx','Sheet2','A3'); %21;
testtype = 'FTP75';
[~,~,vehicle] = xlsread('Book1.xlsx','Sheet1','D1'); %'Y654GYD';
% filename = -['WARNING TEST FILE_' testcll(1,1)] % <<<< Failing
% filename = sprintf('WARNING TEST FILE_%s_%s_%s_%s_%s', testcll, testdate,
% testnumber, testtype, vehicle) % <<<< Failing
% filename = ['WARNING TEST FILE_', testcll, '_', testdate, '_',
% testnumber, '_', testtype, '_', vehicle] % <<<< Failing
saveas(tst2, filename, 'pdf')
I've tried several things with sprintf (i think thats what is supposed to be used) but it can't seem to deal with the imported information being in a cell
Any help would be appreciated.
댓글 수: 3
답변 (1개)
Iman Ansari
2013년 4월 18일
filename = ['WARNING TEST FILE_C2_2013-02-25']
filename(filename=='-')='_'
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!