其他分享
首页 > 其他分享> > D365Excel Import

D365Excel Import

作者:互联网

using OfficeOpenXml;
using OfficeOpenXml.ExcelPackage;
using OfficeOpenXml.ExcelRange;
class ImportTEST extends RunBaseBatch
{
Dialog dialog;
str fileUrl;
FileName FileName;
Counter importedLines;

public boolean canGoBatch()
{
return false;
}

/// <summary>
///
/// </summary>
/// <returns></returns>
public ClassDescription caption()
{
return "@MCS01608";
}

/// <summary>
///
/// </summary>
/// <returns></returns>
public Object dialog()
{
FormBuildButtonControl buttonControl;
DialogGroup dlgGroup;
FormBuildGroupControl buttonGroup;
dialog = super();
dlgGroup = dialog.addGroup('');
buttonGroup = dialog.formBuildDesign().control(dlgGroup.formBuildGroup().id());
buttonControl = buttonGroup.addControl(FormControlType::Button, 'Upload');
buttonControl.text("Upload file");

buttonControl.registerOverrideMethod(methodStr(FormButtonControl, clicked),
methodStr(MSUPCProductTableImport, uploadClickedEvent),
this);
return dialog;

}

private void uploadClickedEvent(FormButtonControl _formButtonControl)
{
FileUploadTemporaryStorageResult result = File::GetFileFromUser() as FileUploadTemporaryStorageResult;

if (result && result.getUploadStatus())
{
result.getFileContentType();
fileUrl = result.getDownloadUrl();
FileName = result.getFileName();
}

}

void run()
{
#OCCRetryCount;
try
{
ttsbegin;
this.buildData();
ttscommit;
info(strFmt("@SYS59939", importedLines, fileName));
}
catch (Exception::Deadlock)
{
retry;
}
catch (Exception::UpdateConflict)
{
if (appl.ttsLevel() == 0)
{
if (xSession::currentRetryCount() >= #RetryNum)
{
throw Exception::UpdateConflictNotRecovered;
}
else
{
retry;
}
}
else
{
throw Exception::UpdateConflict;
}
}
}


public void buildData()
{
System.IO.Stream stream;
#File

stream = File::UseFileFromURL(fileUrl);
using (ExcelPackage package = new ExcelPackage(stream))
{
OfficeOpenXml.ExcelWorksheet _worksheet;

package.Load(stream);
ExcelWorksheet worksheet = package.get_Workbook().get_Worksheets().get_Item(1);
OfficeOpenXml.ExcelRange range = worksheet.Cells;
int rowCount = worksheet.Dimension.End.Row - worksheet.Dimension.Start.Row + 1;
for (int i = 2; i <= rowCount; i++)
{

}
}

 

protected boolean canGoBatchJournal()
{
return false;
}

}

标签:D365Excel,OfficeOpenXml,worksheet,return,result,dialog,using,Import
来源: https://www.cnblogs.com/kang01/p/15510392.html