필터 지우기
필터 지우기

Unable to write data in already open .xlsx file

조회 수: 6 (최근 30일)
Kuber Dwivedi
Kuber Dwivedi 2022년 9월 2일
댓글: dpb 2022년 9월 28일
I am writing the data in an .xlsx file , but when the user opens that file its denied to write the data and give an error "Unable to write to file 'D:\Fuel_Cell_Stack_GUI_Final_V.21\Temp_09-02-2022_16-06-08.xlsx'. You may not have write permissions or the file may be open by another application.
here is my code
pgRx_Ecu_Anlog.FC_IO_Status= 1;
pgRx_Ecu_Anlog.FC_Pack_Voltage=2;
pgRx_Ecu_Anlog.Stack_current= 3;
pgRx_Ecu_Anlog.SOC= 4
pgRx_Ecu_Anlog.Average_Temperarture_of_Pack=5;
canLog = struct2table(pgRx_Ecu_Anlog)
FileName = sprintf('Temp_%s.xlsx', datestr(now,'mm-dd-yyyy_HH-MM-SS'));
writetable(canLog,FileName,'WriteMode','append')
% it write the data but when the xlsx file is already open it gives error"
  댓글 수: 2
Mathieu NOE
Mathieu NOE 2022년 9월 2일
hello
you cannot write from matlab in a excel file that is opened
Kuber Dwivedi
Kuber Dwivedi 2022년 9월 28일
Thank you

댓글을 달려면 로그인하십시오.

답변 (1개)

dpb
dpb 2022년 9월 2일
<microsoft.com Excel/use-shared-workbook> explains how to save a workbook as shared for simultaneous access. I've not tried this with the MATLAB interface functions as to whether it is successful in that scenario or not...
  댓글 수: 2
Kuber Dwivedi
Kuber Dwivedi 2022년 9월 28일
Thank you, but it's not working
dpb
dpb 2022년 9월 28일
As noted, I hadn't physically tried with MATLAB high level functions.
It's a requirement, but not sufficient in and of itself -- the other app has to also play by the rule and open with shared permissions instead wanting exclusive as well...your only chance would be with COM then.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Use COM Objects in MATLAB에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by