Excel ファイルのシート名を変更することはできますか?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MATLAB から Excel を利用するために ACTXSERVER を使用しています。ヘルプドキュメントには以下のようなコードがありますが、ワークブック内のシート名を変更する方法がわかりません。
filename = 'C:\SomeExcelFile.xls';
% Open Excel Automation server
Excel = actxserver('Excel.Application');
% Make Excel visible
Excel.Visible=1;
% Open Excel file
Workbook = Excel.Workbooks.Open(filename);
% Get the list of sheets in the workbook
Sheets = Excel.ActiveWorkbook.Sheets;
Respuesta aceptada
MathWorks Support Team
el 8 de Jul. de 2013
XLSWRITEではシート名の変更はできません。
その代わりに、MATLAB上でExcelのオートメーションサーバーを使用し、シートのオブジェクトの"Name"プロパティにより変更が可能です。
%ファイル名の指定(フルパスで指定)
filename = 'C:\SomeExcelFile.xls';
% Excelのオートメーションサーバーを開く
Excel = actxserver('Excel.Application');
% Excelを表示
Excel.Visible=1;
% ファイルを開く
Workbook = Excel.Workbooks.Open(filename);
% シートのリストを取得
Sheets = Excel.ActiveWorkbook.Sheets;
% シートの名前変更
Sheets.Item(1).Name = 'This is sheet 1';
%ファイルの保存
Workbook.Save();
%後処理
Excel.Quit();
Excel.delete();
clear Excel;
clear Workbook;
clear Sheets;
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre MATLAB の COM オブジェクト en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!