If you can run code outside, like from Code Builder with a py file, then the following code will take XY data in column A and B and add fitted X and Y in the next two columns, and also add a comment to the last column to show the fitting parameters:
import originpro as op
wks = op.find_sheet()
model = op.NLFit('Line')
model.set_data(wks, 0, 1)
model.fit()
rr = model.result()
a = rr['A']
b = rr['B']
r2=rr['cod']
label = f'Slope={b:6.3}, R^2={r2:6.3}'
x = [1,2,3]
y = [a + b * v for v in x]
wks.from_list(2, x)
wks.from_list(3, y)
wks.set_label(3, label, 'C')
To use this in a column formula, setup worksheet with 4 columns, XY in first two and fit data X in column C, and resulting fit Y in column D. You can set recalculate to Auto so you can change the fit X in column C and see D update.
in Column D, Before Formula Script:
string str$;
str$, col(D)=py.myfit(col(C));
col(D)[C]$=str$;
Python Function:
import originpro as op
def myfit(fitx):
'''T:F'''
wks = op.find_sheet()
model = op.NLFit('Line')
model.set_data(wks, 0, 1)
model.fit()
rr = model.result()
a = rr['A']
b = rr['B']
r2=rr['cod']
label = f'Slope={b:6.3}, R^2={r2:6.3}'
fity = [a + b * v for v in fitx]
return label, fity
CP