Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hello everyone,
I want to write data from Mathcad to an Exceldocument, where already data is saved.
The original data for example looks like this:
I want to overwrite the data in a special row. In the other rows, the data should not change. Below is my Mathcad file with 3 ways of writing data to Excel. The data should be written to the row with the number of the ID (here 3).
______________________________________________________________________________________________
The Variable k overwrite the first row, so this is wrong, see below.
________________________________________________________________________________________________
The Variable kk here gives the right solution, but only for ID=3, see below. So I find a third way, where I can change the ID. But if I have 1000 ID´s, this solution is very time-consuming.
Is there a better way to solve the problem?
Thank you
Stephan
Solved! Go to Solution.
Try using the "concat" & "num2str" functions. I didn't test it, but I think the following should work:
WRITEEXCEL(".\a.xlsx",M,concat("[3]A",num2str(ID)))
Try using the "concat" & "num2str" functions. I didn't test it, but I think the following should work:
WRITEEXCEL(".\a.xlsx",M,concat("[3]A",num2str(ID)))
Mark Gase wrote:
Try using the "concat" & "num2str" functions. I didn't test it, but I think the following should work:
WRITEEXCEL(".\a.xlsx",M,concat("[3]A",num2str(ID)))
That will work. There was a recent thread on a similar subject: https://community.ptc.com/t5/PTC-Mathcad/Excel-component-in-a-program/td-p/226416.
One of the differences between that thread and this one, is that column ID extended into AA, etc. One solution to that particular problem is to use R1C1 notation, which is simple using just num2str. However, most people are more familiar with, and can lookup a lot easier, A1 addresses, which means converting the column number to its corresponding string.
Stuart