- Replace placeholders like 'your_excel_file.xlsx' and cell ranges with your actual data.
- Explore the topics in: https://www.mathworks.com/help/matlab/ref/actxserver.html
Basic use of Interface.000208DA_0000_0000_C000_000000000046
조회 수: 5 (최근 30일)
이전 댓글 표시
I am at the very first use of Interface.000208DA_0000_0000_C000_000000000046, since I need to change an excel, in its fomat and contents, automatically. I have some basic questions, since I have not found clear documentation on them.
1) I know some basic commands, i.e. how to open the excel sheet via "actxserver" and "Workbooks", how to generate "Sheets" objects. I would like to know how can I copy in an excel file, once I have opned it, cells from a sheet to another sheet. These cells shall contain formulas to elaborate the contents of other column that I have generated via a routine of mine.
2) How can I insert in a cell some mixed text, like "Δ Fuel Consumption" (where there is one character using "Symbol" font and the rest is "Calibri")?
댓글 수: 0
답변 (1개)
UDAYA PEDDIRAJU
2024년 6월 14일
Hi Mauro,
I can help you with those basic tasks using MATLAB Interface (.000208DA_0000_0000_C000_000000000046)! Here's how you can tackle your questions:
1. Copying Cells with Formulas between Sheets:
Here's how to copy cells from one sheet to another, including formulas:
% Open the Excel workbook
excel = actxserver('Excel.Application');
workbook = excel.Workbooks.Open('your_excel_file.xlsx');
% Get the source and destination sheets
sourceSheet = workbook.Sheets('Sheet1'); % Replace with actual sheet name
destSheet = workbook.Sheets('Sheet2'); % Replace with actual sheet name
% Define the range of cells to copy (replace with your cell range)
sourceRange = sourceSheet.Range('A1:B10'); % Example range
% Copy the range with formulas to the destination sheet
destRange = destSheet.Range('C1'); % Top-left corner of destination range
sourceRange.Copy.PasteSpecial destRange, xlPasteValuesAndFormulas;
% Close the workbook and quit Excel
workbook.Close;
excel.Quit;
2. Inserting Mixed Text with Font Formatting:
To insert mixed text with different fonts in a cell, you can use the Value and Font properties:
% Get the destination cell (replace with your cell reference)
destCell = destSheet.Range('A1');
% Set the mixed text content
destCell.Value = 'Δ Fuel Consumption';
% Apply font formatting (replace with desired font names)
destCell.Font.Name = 'Calibri'; % Set font for most of the text
destCell.Characters.Item(1).Font.Name = 'Symbol'; % Set font for Δ symbol
% (Optional) Set specific font properties for the symbol
destCell.Characters.Item(1).Font.Size = 12; % Example: Set symbol font size
Tips:
댓글 수: 4
Walter Roberson
2024년 6월 16일
It looks like more correct would be
sourceSheet = workbook.Sheets.Item('Sheet1');
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!