The translation for this routine is shown below. I have not tested it so that part is up to you. Please note the literal that says Place the javascipt in here. I had to remove actual javascript as it was causing formatting problems with this post. Add back the original content before using.
$set ilusing"System" $set ilusing"System.Collections.Generic" $set ilusing"System.Web" $set ilusing"System.Web.UI" $set ilusing"System.Web.UI.WebControls" $set ilusing"OfficeOpenXml" $set ilusing"System.IO" $set ilusing"OfficeOpenXml.Style" $set ilusing"System.Drawing" $set ilusing"System.Text" class-id EPPlusWebSample.GetSample is partial inherits type System.Web.UI.Page public. working-storage section. method-id Page_Load protected. local-storage section. procedure division using by value param-sender as object param-e as type System.EventArgs. evaluate Request::QueryString["Sample"] when "1" invoke Sample1 when "2" invoke Sample2 when "3" invoke Sample3 when "4" invoke Sample4 when other invoke Response::Write("place the javascript in here") end-evaluate goback. end method. method-id Sample1 private. procedure division. declare pck as type ExcelPackage = new ExcelPackage declare ws = pck::Workbook::Worksheets::Add("Sample1") set ws::Cells["A1"]::Value to "Sample 1" set ws::Cells["A1"]::Style::Font::Bold to true declare shape = ws::Drawings::AddShape("Shape1", type eShapeStyle::Rect) invoke shape::SetPosition(50, 200) invoke shape::SetSize(200, 100) set shape::Text to "Sample 1 saves to the Response.OutputStream" invoke pck::SaveAs(Response::OutputStream) set Response::ContentType to "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" invoke Response::AddHeader("content-disposition", "attachment; filename=Sample1.xlsx") goback. end method. *>/// *>/// Sample 2 *>/// Demonstrates the GetAsByteArray method *>/// method-id Sample2 private. procedure division. declare pck as type ExcelPackage = new ExcelPackage declare ws = pck::Workbook::Worksheets::Add("Sample2") set ws::Cells["A1"]::Value to "Sample 2" set ws::Cells["A1"]::Style::Font::Bold to true declare shape = ws::Drawings::AddShape("Shape1", type eShapeStyle::Rect) invoke shape::SetPosition(50, 200) invoke shape::SetSize(200, 100) set shape::Text = "Sample 2 outputs the sheet using the Response.BinaryWrite method" invoke Response::BinaryWrite(pck::GetAsByteArray()) set Response::ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" invoke Response::AddHeader("content-disposition", "attachment; filename=Sample2.xlsx") goback. end method. *>/// *>/// Sample 3 *>/// Uses a cached template *>/// method-id Sample3 private. procedure division. if Application["Sample3Template"] = null *>Check if the template is loaded *>Here we create the template. *>As an alternative the template could be loaded from disk or from a resource. declare pckTemplate as type ExcelPackage = new ExcelPackage declare wsTemplate = pckTemplate::Workbook::Worksheets::Add("Sample3") set wsTemplate::Cells["A1"]::Value = "Sample 3" set wsTemplate::Cells["A1"]::Style::Font::Bold = true declare shape = wsTemplate::Drawings::AddShape("Shape1", type eShapeStyle::Rect) invoke shape::SetPosition(50, 200) invoke shape::SetSize(200, 100) set shape::Text = "Sample 3 uses a template that is stored in the application cashe." invoke pckTemplate::Save set Application["Sample3Template"] = pckTemplate::Stream end-if *>Open the new package with the template stream. *>The template stream is copied to the new stream in the constructor declare pck as type ExcelPackage = new ExcelPackage(new MemoryStream, Application["Sample3Template"] as type Stream) declare ws = pck::Workbook::Worksheets[1] declare row as binary-long = new type Random()::Next(10) + 10 *>Pick a random row to print the text set ws::Cells[row, 1]::Value = "We make a small change here, after the template has been loaded..." set ws::Cells[row, 1, row, 5]::Style::Fill::PatternType = type ExcelFillStyle::Solid invoke ws::Cells[row, 1, row, 5]::Style::Fill::BackgroundColor::SetColor(type Color::LightGoldenrodYellow) invoke Response::BinaryWrite(pck::GetAsByteArray()) set Response::ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" invoke Response::AddHeader("content-disposition", "attachment; filename=Sample3.xlsx") goback. end method. method-id Sample4 private. procedure division. declare pck = new type ExcelPackage *>Add a worksheet. declare ws = pck::Workbook::Worksheets::Add("VBA Sample") invoke ws::Drawings::AddShape("VBASampleRect", type eShapeStyle::RoundRect) *>Create a vba project invoke pck::Workbook::CreateVBAProject() *>Now add some code that creates a bubble chart... declare sb = new type StringBuilder invoke sb::AppendLine("Private Sub Workbook_Open()") invoke sb::AppendLine(" [VBA Sample].Shapes(""VBASampleRect"").TextEffect.Text = ""This text is set from VBA!""") invoke sb::AppendLine("End Sub") set pck::Workbook::CodeModule::Code = sb::ToString invoke Response::BinaryWrite(pck::GetAsByteArray()) set Response::ContentType = "application/vnd.ms-excel.sheet.macroEnabled.12" *>.xlsm files uses a different contenttype than .xlsx invoke Response::AddHeader("content-disposition", "attachment; filename=Sample4.xlsm") goback. end method. end class.