edit textstyle from excelsheet in matlab

You can edit the text style of Excel sheet in Matlab using the following steps:

  1. Load the Excel file in Matlab using the xlsread command.
[num,txt,raw] = xlsread('filename.xlsx');
42 chars
2 lines

Note: num will contain numeric data, txt will contain text data, and raw will contain both.

  1. Get the Excel COM object using the actxserver command.
Excel = actxserver('Excel.Application');
41 chars
2 lines
  1. Open the Excel file in Matlab using the Excel.Workbooks.Open method.
Workbook = Excel.Workbooks.Open('filename.xlsx');
50 chars
2 lines
  1. Get the range of cells for which you want to change the text style using the Excel.Range method.
Range = Workbook.ActiveSheet.Range('A1:B2');
45 chars
2 lines
  1. Change the text style of the cells using the Excel.Range.Font method.
Range.Font.Bold = true;
Range.Font.Italic = true;
Range.Font.Underline = true;
79 chars
4 lines
  1. Save and close the Excel file using the Workbook.Save and Workbook.Close methods.
Workbook.Save;
Workbook.Close;
31 chars
3 lines
  1. Quit the Excel object using the Excel.Quit method.
Excel.Quit;
12 chars
2 lines

Note: You can change the text style properties like Bold, Italic and Underline according to your need.

related categories

gistlibby LogSnag