More efficient way to export output to Excel

6 ビュー (過去 30 日間)
AND
AND 2013 年 8 月 30 日
Hello,
I am currently following this method to export the results to one Excel file:
xlswrite('C:\Users\...\Graph.xlsx',{'A' 'B' 'C' 'D'},'Sheet1','A1');
xlswrite('C:\Users\...\Graph.xlsx',PriceA','Sheet1','A2');
xlswrite('C:\Users\...\Graph.xlsx',PriceB','Sheet1','A2');
.
.
etc
There must be a more efficient way that opens the excel file only once, but I am not able to locate it. It is not really logical to write every time separately to the same file.
Any assistance is appreciated.
Thanks

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 8 月 30 日
編集済み: Azzi Abdelmalek 2013 年 8 月 30 日
EDIT
header={'A' 'B' 'C' };
priceA=[1 2 3]';
priceB=[4 5 6 8 9 1 0 12 15 20]';
priceC=[7 8 9 10]';
max_n=10;
tr=@(price)[num2cell(price) ;repmat({[]},max_n-numel(price),1)]
priceA=tr(priceA)
priceB=tr(priceB)
priceC=tr(priceC)
M=[header;[priceA priceB priceC]]
xlswrite('C:\Users\...\Graph.xlsx',M)
  15 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 8 月 30 日
編集済み: Azzi Abdelmalek 2013 年 8 月 30 日
Sorry, there is a mistake. write D=trc(D) instead of D=trc(C)
AND
AND 2013 年 8 月 30 日
Thanks Azzi- It is working perfectly now.
Best of Regards//

サインインしてコメントする。

その他の回答 (1 件)

Shashank Prasanna
Shashank Prasanna 2013 年 8 月 30 日
編集済み: Shashank Prasanna 2013 年 8 月 30 日
You can use the com interface directly. XLSWRITE does this each time when you call it.
Here is an example:
More about COM Interface:
  2 件のコメント
AND
AND 2013 年 8 月 30 日
Thanks for your answer Shashank, but my issue is a little different.
Regards-
Shashank Prasanna
Shashank Prasanna 2013 年 8 月 30 日
You said your issue is the following. Quote:
There must be a more efficient way that opens the excel file only once, but I am not able to locate it. It is not really logical to write every time separately to the same file.
What I gave you does exactly that.
Regards,

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by