diff --git a/Getting Started/Docker/Alpine/Create Excel/Create Excel.sln b/Getting Started/Docker/Alpine/Create Excel/Create Excel.sln new file mode 100644 index 00000000..c82ebcb0 --- /dev/null +++ b/Getting Started/Docker/Alpine/Create Excel/Create Excel.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create Excel", "Create Excel\Create Excel.csproj", "{D9C2A5D3-F4C7-411F-A6D0-0BA063580B93}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D9C2A5D3-F4C7-411F-A6D0-0BA063580B93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D9C2A5D3-F4C7-411F-A6D0-0BA063580B93}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D9C2A5D3-F4C7-411F-A6D0-0BA063580B93}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D9C2A5D3-F4C7-411F-A6D0-0BA063580B93}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D4C62E85-3E5C-46FD-AA63-A735AF510183} + EndGlobalSection +EndGlobal diff --git a/Getting Started/Docker/Alpine/Create Excel/Create Excel/Create Excel.csproj b/Getting Started/Docker/Alpine/Create Excel/Create Excel/Create Excel.csproj new file mode 100644 index 00000000..6fbaf67f --- /dev/null +++ b/Getting Started/Docker/Alpine/Create Excel/Create Excel/Create Excel.csproj @@ -0,0 +1,14 @@ + + + + Exe + netcoreapp3.1 + Create_Excel + Linux + + + + + + + diff --git a/Getting Started/Docker/Alpine/Create Excel/Create Excel/Create Excel.csproj.user b/Getting Started/Docker/Alpine/Create Excel/Create Excel/Create Excel.csproj.user new file mode 100644 index 00000000..e681dafe --- /dev/null +++ b/Getting Started/Docker/Alpine/Create Excel/Create Excel/Create Excel.csproj.user @@ -0,0 +1,6 @@ + + + + Docker + + \ No newline at end of file diff --git a/Getting Started/Docker/Alpine/Create Excel/Create Excel/Data/AdventureCycles-Logo.png b/Getting Started/Docker/Alpine/Create Excel/Create Excel/Data/AdventureCycles-Logo.png new file mode 100644 index 00000000..2b6003c2 Binary files /dev/null and b/Getting Started/Docker/Alpine/Create Excel/Create Excel/Data/AdventureCycles-Logo.png differ diff --git a/Getting Started/Docker/Alpine/Create Excel/Create Excel/Dockerfile b/Getting Started/Docker/Alpine/Create Excel/Create Excel/Dockerfile new file mode 100644 index 00000000..9ce58831 --- /dev/null +++ b/Getting Started/Docker/Alpine/Create Excel/Create Excel/Dockerfile @@ -0,0 +1,22 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:3.1-alpine3.12 AS base +RUN apk update && apk upgrade && apk add fontconfig +RUN apk add --update ttf-dejavu fontconfig +WORKDIR /app + +FROM mcr.microsoft.com/dotnet/sdk:3.1-alpine3.12 AS build +WORKDIR /src +COPY ["Create Excel.csproj", "."] +RUN dotnet restore "./Create Excel.csproj" +COPY . . +WORKDIR "/src/." +RUN dotnet build "Create Excel.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "Create Excel.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Create Excel.dll"] \ No newline at end of file diff --git a/Getting Started/Docker/Alpine/Create Excel/Create Excel/Program.cs b/Getting Started/Docker/Alpine/Create Excel/Create Excel/Program.cs new file mode 100644 index 00000000..832bbf73 --- /dev/null +++ b/Getting Started/Docker/Alpine/Create Excel/Create Excel/Program.cs @@ -0,0 +1,189 @@ +using Syncfusion.XlsIO; +using Syncfusion.Drawing; +using System; +using System.IO; + +namespace Create_Excel +{ + internal class Program + { + static void Main(string[] args) + { + //Create an instance of ExcelEngine + using (ExcelEngine excelEngine = new ExcelEngine()) + { + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + + //Create a workbook + IWorkbook workbook = application.Workbooks.Create(1); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Adding a picture + FileStream imageStream = new FileStream("Data/AdventureCycles-Logo.png", FileMode.Open, FileAccess.Read); + IPictureShape shape = worksheet.Pictures.AddPicture(1, 1, imageStream, 20, 20); + + //Disable gridlines in the worksheet + worksheet.IsGridLinesVisible = false; + + //Enter values to the cells from A3 to A5 + worksheet.Range["A3"].Text = "46036 Michigan Ave"; + worksheet.Range["A4"].Text = "Canton, USA"; + worksheet.Range["A5"].Text = "Phone: +1 231-231-2310"; + + //Make the text bold + worksheet.Range["A3:A5"].CellStyle.Font.Bold = true; + + //Merge cells + worksheet.Range["D1:E1"].Merge(); + + //Enter text to the cell D1 and apply formatting. + worksheet.Range["D1"].Text = "INVOICE"; + worksheet.Range["D1"].CellStyle.Font.Bold = true; + worksheet.Range["D1"].CellStyle.Font.RGBColor = Color.FromArgb(42, 118, 189); + worksheet.Range["D1"].CellStyle.Font.Size = 35; + + //Apply alignment in the cell D1 + worksheet.Range["D1"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignRight; + worksheet.Range["D1"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignTop; + + //Enter values to the cells from D5 to E8 + worksheet.Range["D5"].Text = "INVOICE#"; + worksheet.Range["E5"].Text = "DATE"; + worksheet.Range["D6"].Number = 1028; + worksheet.Range["E6"].Value = "12/31/2018"; + worksheet.Range["D7"].Text = "CUSTOMER ID"; + worksheet.Range["E7"].Text = "TERMS"; + worksheet.Range["D8"].Number = 564; + worksheet.Range["E8"].Text = "Due Upon Receipt"; + + //Apply RGB backcolor to the cells from D5 to E8 + worksheet.Range["D5:E5"].CellStyle.Color = Color.FromArgb(42, 118, 189); + worksheet.Range["D7:E7"].CellStyle.Color = Color.FromArgb(42, 118, 189); + + //Apply known colors to the text in cells D5 to E8 + worksheet.Range["D5:E5"].CellStyle.Font.Color = ExcelKnownColors.White; + worksheet.Range["D7:E7"].CellStyle.Font.Color = ExcelKnownColors.White; + + //Make the text as bold from D5 to E8 + worksheet.Range["D5:E8"].CellStyle.Font.Bold = true; + + //Apply alignment to the cells from D5 to E8 + worksheet.Range["D5:E8"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter; + worksheet.Range["D5:E5"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignCenter; + worksheet.Range["D7:E7"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignCenter; + worksheet.Range["D6:E6"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignTop; + + //Enter value and applying formatting in the cell A7 + worksheet.Range["A7"].Text = " BILL TO"; + worksheet.Range["A7"].CellStyle.Color = Color.FromArgb(42, 118, 189); + worksheet.Range["A7"].CellStyle.Font.Bold = true; + worksheet.Range["A7"].CellStyle.Font.Color = ExcelKnownColors.White; + + //Apply alignment + worksheet.Range["A7"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignLeft; + worksheet.Range["A7"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignCenter; + + //Enter values in the cells A8 to A12 + worksheet.Range["A8"].Text = "Steyn"; + worksheet.Range["A9"].Text = "Great Lakes Food Market"; + worksheet.Range["A10"].Text = "20 Whitehall Rd"; + worksheet.Range["A11"].Text = "North Muskegon,USA"; + worksheet.Range["A12"].Text = "+1 231-654-0000"; + + //Create a Hyperlink for e-mail in the cell A13 + IHyperLink hyperlink = worksheet.HyperLinks.Add(worksheet.Range["A13"]); + hyperlink.Type = ExcelHyperLinkType.Url; + hyperlink.Address = "Steyn@greatlakes.com"; + hyperlink.ScreenTip = "Send Mail"; + + //Merge column A and B from row 15 to 22 + worksheet.Range["A15:B15"].Merge(); + worksheet.Range["A16:B16"].Merge(); + worksheet.Range["A17:B17"].Merge(); + worksheet.Range["A18:B18"].Merge(); + worksheet.Range["A19:B19"].Merge(); + worksheet.Range["A20:B20"].Merge(); + worksheet.Range["A21:B21"].Merge(); + worksheet.Range["A22:B22"].Merge(); + + //Enter details of products and prices + worksheet.Range["A15"].Text = " DESCRIPTION"; + worksheet.Range["C15"].Text = "QTY"; + worksheet.Range["D15"].Text = "UNIT PRICE"; + worksheet.Range["E15"].Text = "AMOUNT"; + worksheet.Range["A16"].Text = "Cabrales Cheese"; + worksheet.Range["A17"].Text = "Chocos"; + worksheet.Range["A18"].Text = "Pasta"; + worksheet.Range["A19"].Text = "Cereals"; + worksheet.Range["A20"].Text = "Ice Cream"; + worksheet.Range["C16"].Number = 3; + worksheet.Range["C17"].Number = 2; + worksheet.Range["C18"].Number = 1; + worksheet.Range["C19"].Number = 4; + worksheet.Range["C20"].Number = 3; + worksheet.Range["D16"].Number = 21; + worksheet.Range["D17"].Number = 54; + worksheet.Range["D18"].Number = 10; + worksheet.Range["D19"].Number = 20; + worksheet.Range["D20"].Number = 30; + worksheet.Range["D23"].Text = "Total"; + + //Apply number format + worksheet.Range["D16:E22"].NumberFormat = "$.00"; + worksheet.Range["E23"].NumberFormat = "$.00"; + + //Apply incremental formula for column Amount by multiplying Qty and UnitPrice + application.EnableIncrementalFormula = true; + worksheet.Range["E16:E20"].Formula = "=C16*D16"; + + //Formula for Sum the total + worksheet.Range["E23"].Formula = "=SUM(E16:E22)"; + + //Apply borders + worksheet.Range["A16:E22"].CellStyle.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin; + worksheet.Range["A16:E22"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin; + worksheet.Range["A16:E22"].CellStyle.Borders[ExcelBordersIndex.EdgeTop].Color = ExcelKnownColors.Grey_25_percent; + worksheet.Range["A16:E22"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].Color = ExcelKnownColors.Grey_25_percent; + worksheet.Range["A23:E23"].CellStyle.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin; + worksheet.Range["A23:E23"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin; + worksheet.Range["A23:E23"].CellStyle.Borders[ExcelBordersIndex.EdgeTop].Color = ExcelKnownColors.Black; + worksheet.Range["A23:E23"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].Color = ExcelKnownColors.Black; + + //Apply font setting for cells with product details + worksheet.Range["A3:E23"].CellStyle.Font.FontName = "Arial"; + worksheet.Range["A3:E23"].CellStyle.Font.Size = 10; + worksheet.Range["A15:E15"].CellStyle.Font.Color = ExcelKnownColors.White; + worksheet.Range["A15:E15"].CellStyle.Font.Bold = true; + worksheet.Range["D23:E23"].CellStyle.Font.Bold = true; + + //Apply cell color + worksheet.Range["A15:E15"].CellStyle.Color = Color.FromArgb(42, 118, 189); + + //Apply alignment to cells with product details + worksheet.Range["A15"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignLeft; + worksheet.Range["C15:C22"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter; + worksheet.Range["D15:E15"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter; + + //Apply row height and column width to look good + worksheet.Range["A1"].ColumnWidth = 36; + worksheet.Range["B1"].ColumnWidth = 11; + worksheet.Range["C1"].ColumnWidth = 8; + worksheet.Range["D1:E1"].ColumnWidth = 18; + worksheet.Range["A1"].RowHeight = 47; + worksheet.Range["A2"].RowHeight = 15; + worksheet.Range["A3:A4"].RowHeight = 15; + worksheet.Range["A5"].RowHeight = 18; + worksheet.Range["A6"].RowHeight = 29; + worksheet.Range["A7"].RowHeight = 18; + worksheet.Range["A8"].RowHeight = 15; + worksheet.Range["A9:A14"].RowHeight = 15; + worksheet.Range["A15:A23"].RowHeight = 18; + + //Saving the Excel to the MemoryStream + FileStream outputStream = new FileStream("Output.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite); + workbook.SaveAs(outputStream); + } + } + } +} diff --git a/Getting Started/Docker/Alpine/Create Excel/Create Excel/Properties/launchSettings.json b/Getting Started/Docker/Alpine/Create Excel/Create Excel/Properties/launchSettings.json new file mode 100644 index 00000000..99916c3a --- /dev/null +++ b/Getting Started/Docker/Alpine/Create Excel/Create Excel/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "Create Excel": { + "commandName": "Project" + }, + "Docker": { + "commandName": "Docker" + } + } +} \ No newline at end of file diff --git a/Getting Started/Docker/Alpine/Edit Excel/Edit Excel.sln b/Getting Started/Docker/Alpine/Edit Excel/Edit Excel.sln new file mode 100644 index 00000000..a8acb272 --- /dev/null +++ b/Getting Started/Docker/Alpine/Edit Excel/Edit Excel.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Edit Excel", "Edit Excel\Edit Excel.csproj", "{DFF001B6-2DCE-43BF-9935-C69634E05A4D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DFF001B6-2DCE-43BF-9935-C69634E05A4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DFF001B6-2DCE-43BF-9935-C69634E05A4D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DFF001B6-2DCE-43BF-9935-C69634E05A4D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DFF001B6-2DCE-43BF-9935-C69634E05A4D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {17D9705F-8C8D-4068-B04B-EC7B54A590EF} + EndGlobalSection +EndGlobal diff --git a/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Data/InputTemplate.xlsx b/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Data/InputTemplate.xlsx new file mode 100644 index 00000000..8be31fc9 Binary files /dev/null and b/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Data/InputTemplate.xlsx differ diff --git a/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Dockerfile b/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Dockerfile new file mode 100644 index 00000000..120bb345 --- /dev/null +++ b/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Dockerfile @@ -0,0 +1,22 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:3.1-alpine3.12 AS base +RUN apk update && apk upgrade && apk add fontconfig +RUN apk add --update ttf-dejavu fontconfig +WORKDIR /app + +FROM mcr.microsoft.com/dotnet/sdk:3.1-alpine3.12 AS build +WORKDIR /src +COPY ["Edit Excel.csproj", "."] +RUN dotnet restore "./Edit Excel.csproj" +COPY . . +WORKDIR "/src/." +RUN dotnet build "Edit Excel.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "Edit Excel.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Edit Excel.dll"] \ No newline at end of file diff --git a/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Edit Excel.csproj b/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Edit Excel.csproj new file mode 100644 index 00000000..eed1ecb9 --- /dev/null +++ b/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Edit Excel.csproj @@ -0,0 +1,15 @@ + + + + Exe + netcoreapp3.1 + Edit_Excel + Linux + + + + + + + + diff --git a/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Edit Excel.csproj.user b/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Edit Excel.csproj.user new file mode 100644 index 00000000..e681dafe --- /dev/null +++ b/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Edit Excel.csproj.user @@ -0,0 +1,6 @@ + + + + Docker + + \ No newline at end of file diff --git a/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Program.cs b/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Program.cs new file mode 100644 index 00000000..b4831cb1 --- /dev/null +++ b/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Program.cs @@ -0,0 +1,40 @@ +using Syncfusion.XlsIO; +using System; +using System.IO; +using static System.Net.Mime.MediaTypeNames; + +namespace Edit_Excel +{ + internal class Program + { + static void Main(string[] args) + { + using (ExcelEngine excelEngine = new ExcelEngine()) + { + + //Instantiate the Excel application object + IApplication application = excelEngine.Excel; + + //Assigns default application version + application.DefaultVersion = ExcelVersion.Xlsx; + + //A existing workbook is opened. + FileStream sampleFile = new FileStream("Data/InputTemplate.xlsx", FileMode.Open); + IWorkbook workbook = application.Workbooks.Open(sampleFile); + + //Access first worksheet from the workbook. + IWorksheet worksheet = workbook.Worksheets[0]; + + //Set Text in cell A3. + worksheet.Range["A3"].Text = "Hello World"; + + //Saving the workbook as stream + FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); + workbook.SaveAs(stream); + + //Dispose the stream + stream.Dispose(); + } + } + } +} diff --git a/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Properties/launchSettings.json b/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Properties/launchSettings.json new file mode 100644 index 00000000..5502a70e --- /dev/null +++ b/Getting Started/Docker/Alpine/Edit Excel/Edit Excel/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "Edit Excel": { + "commandName": "Project" + }, + "Docker": { + "commandName": "Docker" + } + } +} \ No newline at end of file diff --git a/Getting Started/Docker/Debian/Create Excel/Create Excel.sln b/Getting Started/Docker/Debian/Create Excel/Create Excel.sln new file mode 100644 index 00000000..ec29b022 --- /dev/null +++ b/Getting Started/Docker/Debian/Create Excel/Create Excel.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create Excel", "Create Excel\Create Excel.csproj", "{E151DF98-BA1B-4960-A257-A61313573193}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E151DF98-BA1B-4960-A257-A61313573193}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E151DF98-BA1B-4960-A257-A61313573193}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E151DF98-BA1B-4960-A257-A61313573193}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E151DF98-BA1B-4960-A257-A61313573193}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3B4D2322-8A42-4D4F-9F2F-5944CE0DD387} + EndGlobalSection +EndGlobal diff --git a/Getting Started/Docker/Debian/Create Excel/Create Excel/Create Excel.csproj b/Getting Started/Docker/Debian/Create Excel/Create Excel/Create Excel.csproj new file mode 100644 index 00000000..abdd97ce --- /dev/null +++ b/Getting Started/Docker/Debian/Create Excel/Create Excel/Create Excel.csproj @@ -0,0 +1,15 @@ + + + + Exe + netcoreapp3.1 + Create_Excel + Linux + + + + + + + + diff --git a/Getting Started/Docker/Debian/Create Excel/Create Excel/Create Excel.csproj.user b/Getting Started/Docker/Debian/Create Excel/Create Excel/Create Excel.csproj.user new file mode 100644 index 00000000..e681dafe --- /dev/null +++ b/Getting Started/Docker/Debian/Create Excel/Create Excel/Create Excel.csproj.user @@ -0,0 +1,6 @@ + + + + Docker + + \ No newline at end of file diff --git a/Getting Started/Docker/Debian/Create Excel/Create Excel/Data/AdventureCycles-Logo.png b/Getting Started/Docker/Debian/Create Excel/Create Excel/Data/AdventureCycles-Logo.png new file mode 100644 index 00000000..2b6003c2 Binary files /dev/null and b/Getting Started/Docker/Debian/Create Excel/Create Excel/Data/AdventureCycles-Logo.png differ diff --git a/Getting Started/Docker/Debian/Create Excel/Create Excel/Dockerfile b/Getting Started/Docker/Debian/Create Excel/Create Excel/Dockerfile new file mode 100644 index 00000000..5b5c03f9 --- /dev/null +++ b/Getting Started/Docker/Debian/Create Excel/Create Excel/Dockerfile @@ -0,0 +1,21 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:3.1-buster-slim AS base +RUN apt-get update -y && apt-get install fontconfig -y +WORKDIR /app + +FROM mcr.microsoft.com/dotnet/sdk:3.1-buster-slim AS build +WORKDIR /src +COPY ["Create Excel.csproj", "."] +RUN dotnet restore "./Create Excel.csproj" +COPY . . +WORKDIR "/src/." +RUN dotnet build "Create Excel.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "Create Excel.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Create Excel.dll"] \ No newline at end of file diff --git a/Getting Started/Docker/Debian/Create Excel/Create Excel/Program.cs b/Getting Started/Docker/Debian/Create Excel/Create Excel/Program.cs new file mode 100644 index 00000000..cc68b58f --- /dev/null +++ b/Getting Started/Docker/Debian/Create Excel/Create Excel/Program.cs @@ -0,0 +1,190 @@ +using Syncfusion.XlsIO; +using Syncfusion.Drawing; +using System; +using System.IO; + +namespace Create_Excel +{ + internal class Program + { + static void Main(string[] args) + { + //Create an instance of ExcelEngine + using (ExcelEngine excelEngine = new ExcelEngine()) + { + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + + //Create a workbook + IWorkbook workbook = application.Workbooks.Create(1); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Adding a picture + FileStream imageStream = new FileStream("Data/AdventureCycles-Logo.png", FileMode.Open, FileAccess.Read); + IPictureShape shape = worksheet.Pictures.AddPicture(1, 1, imageStream, 20, 20); + + //Disable gridlines in the worksheet + worksheet.IsGridLinesVisible = false; + + //Enter values to the cells from A3 to A5 + worksheet.Range["A3"].Text = "46036 Michigan Ave"; + worksheet.Range["A4"].Text = "Canton, USA"; + worksheet.Range["A5"].Text = "Phone: +1 231-231-2310"; + + //Make the text bold + worksheet.Range["A3:A5"].CellStyle.Font.Bold = true; + + //Merge cells + worksheet.Range["D1:E1"].Merge(); + + //Enter text to the cell D1 and apply formatting. + worksheet.Range["D1"].Text = "INVOICE"; + worksheet.Range["D1"].CellStyle.Font.Bold = true; + worksheet.Range["D1"].CellStyle.Font.RGBColor = Color.FromArgb(42, 118, 189); + worksheet.Range["D1"].CellStyle.Font.Size = 35; + + //Apply alignment in the cell D1 + worksheet.Range["D1"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignRight; + worksheet.Range["D1"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignTop; + + //Enter values to the cells from D5 to E8 + worksheet.Range["D5"].Text = "INVOICE#"; + worksheet.Range["E5"].Text = "DATE"; + worksheet.Range["D6"].Number = 1028; + worksheet.Range["E6"].Value = "12/31/2018"; + worksheet.Range["D7"].Text = "CUSTOMER ID"; + worksheet.Range["E7"].Text = "TERMS"; + worksheet.Range["D8"].Number = 564; + worksheet.Range["E8"].Text = "Due Upon Receipt"; + + //Apply RGB backcolor to the cells from D5 to E8 + worksheet.Range["D5:E5"].CellStyle.Color = Color.FromArgb(42, 118, 189); + worksheet.Range["D7:E7"].CellStyle.Color = Color.FromArgb(42, 118, 189); + + //Apply known colors to the text in cells D5 to E8 + worksheet.Range["D5:E5"].CellStyle.Font.Color = ExcelKnownColors.White; + worksheet.Range["D7:E7"].CellStyle.Font.Color = ExcelKnownColors.White; + + //Make the text as bold from D5 to E8 + worksheet.Range["D5:E8"].CellStyle.Font.Bold = true; + + //Apply alignment to the cells from D5 to E8 + worksheet.Range["D5:E8"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter; + worksheet.Range["D5:E5"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignCenter; + worksheet.Range["D7:E7"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignCenter; + worksheet.Range["D6:E6"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignTop; + + //Enter value and applying formatting in the cell A7 + worksheet.Range["A7"].Text = " BILL TO"; + worksheet.Range["A7"].CellStyle.Color = Color.FromArgb(42, 118, 189); + worksheet.Range["A7"].CellStyle.Font.Bold = true; + worksheet.Range["A7"].CellStyle.Font.Color = ExcelKnownColors.White; + + //Apply alignment + worksheet.Range["A7"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignLeft; + worksheet.Range["A7"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignCenter; + + //Enter values in the cells A8 to A12 + worksheet.Range["A8"].Text = "Steyn"; + worksheet.Range["A9"].Text = "Great Lakes Food Market"; + worksheet.Range["A10"].Text = "20 Whitehall Rd"; + worksheet.Range["A11"].Text = "North Muskegon,USA"; + worksheet.Range["A12"].Text = "+1 231-654-0000"; + + //Create a Hyperlink for e-mail in the cell A13 + IHyperLink hyperlink = worksheet.HyperLinks.Add(worksheet.Range["A13"]); + hyperlink.Type = ExcelHyperLinkType.Url; + hyperlink.Address = "Steyn@greatlakes.com"; + hyperlink.ScreenTip = "Send Mail"; + + //Merge column A and B from row 15 to 22 + worksheet.Range["A15:B15"].Merge(); + worksheet.Range["A16:B16"].Merge(); + worksheet.Range["A17:B17"].Merge(); + worksheet.Range["A18:B18"].Merge(); + worksheet.Range["A19:B19"].Merge(); + worksheet.Range["A20:B20"].Merge(); + worksheet.Range["A21:B21"].Merge(); + worksheet.Range["A22:B22"].Merge(); + + //Enter details of products and prices + worksheet.Range["A15"].Text = " DESCRIPTION"; + worksheet.Range["C15"].Text = "QTY"; + worksheet.Range["D15"].Text = "UNIT PRICE"; + worksheet.Range["E15"].Text = "AMOUNT"; + worksheet.Range["A16"].Text = "Cabrales Cheese"; + worksheet.Range["A17"].Text = "Chocos"; + worksheet.Range["A18"].Text = "Pasta"; + worksheet.Range["A19"].Text = "Cereals"; + worksheet.Range["A20"].Text = "Ice Cream"; + worksheet.Range["C16"].Number = 3; + worksheet.Range["C17"].Number = 2; + worksheet.Range["C18"].Number = 1; + worksheet.Range["C19"].Number = 4; + worksheet.Range["C20"].Number = 3; + worksheet.Range["D16"].Number = 21; + worksheet.Range["D17"].Number = 54; + worksheet.Range["D18"].Number = 10; + worksheet.Range["D19"].Number = 20; + worksheet.Range["D20"].Number = 30; + worksheet.Range["D23"].Text = "Total"; + + //Apply number format + worksheet.Range["D16:E22"].NumberFormat = "$.00"; + worksheet.Range["E23"].NumberFormat = "$.00"; + + //Apply incremental formula for column Amount by multiplying Qty and UnitPrice + application.EnableIncrementalFormula = true; + worksheet.Range["E16:E20"].Formula = "=C16*D16"; + + //Formula for Sum the total + worksheet.Range["E23"].Formula = "=SUM(E16:E22)"; + + //Apply borders + worksheet.Range["A16:E22"].CellStyle.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin; + worksheet.Range["A16:E22"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin; + worksheet.Range["A16:E22"].CellStyle.Borders[ExcelBordersIndex.EdgeTop].Color = ExcelKnownColors.Grey_25_percent; + worksheet.Range["A16:E22"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].Color = ExcelKnownColors.Grey_25_percent; + worksheet.Range["A23:E23"].CellStyle.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin; + worksheet.Range["A23:E23"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin; + worksheet.Range["A23:E23"].CellStyle.Borders[ExcelBordersIndex.EdgeTop].Color = ExcelKnownColors.Black; + worksheet.Range["A23:E23"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].Color = ExcelKnownColors.Black; + + //Apply font setting for cells with product details + worksheet.Range["A3:E23"].CellStyle.Font.FontName = "Arial"; + worksheet.Range["A3:E23"].CellStyle.Font.Size = 10; + worksheet.Range["A15:E15"].CellStyle.Font.Color = ExcelKnownColors.White; + worksheet.Range["A15:E15"].CellStyle.Font.Bold = true; + worksheet.Range["D23:E23"].CellStyle.Font.Bold = true; + + //Apply cell color + worksheet.Range["A15:E15"].CellStyle.Color = Color.FromArgb(42, 118, 189); + + //Apply alignment to cells with product details + worksheet.Range["A15"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignLeft; + worksheet.Range["C15:C22"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter; + worksheet.Range["D15:E15"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter; + + //Apply row height and column width to look good + worksheet.Range["A1"].ColumnWidth = 36; + worksheet.Range["B1"].ColumnWidth = 11; + worksheet.Range["C1"].ColumnWidth = 8; + worksheet.Range["D1:E1"].ColumnWidth = 18; + worksheet.Range["A1"].RowHeight = 47; + worksheet.Range["A2"].RowHeight = 15; + worksheet.Range["A3:A4"].RowHeight = 15; + worksheet.Range["A5"].RowHeight = 18; + worksheet.Range["A6"].RowHeight = 29; + worksheet.Range["A7"].RowHeight = 18; + worksheet.Range["A8"].RowHeight = 15; + worksheet.Range["A9:A14"].RowHeight = 15; + worksheet.Range["A15:A23"].RowHeight = 18; + + //Saving the Excel to the MemoryStream + FileStream outputStream = new FileStream("Output.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite); + workbook.SaveAs(outputStream); + } + } + } +} + diff --git a/Getting Started/Docker/Debian/Create Excel/Create Excel/Properties/launchSettings.json b/Getting Started/Docker/Debian/Create Excel/Create Excel/Properties/launchSettings.json new file mode 100644 index 00000000..99916c3a --- /dev/null +++ b/Getting Started/Docker/Debian/Create Excel/Create Excel/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "Create Excel": { + "commandName": "Project" + }, + "Docker": { + "commandName": "Docker" + } + } +} \ No newline at end of file diff --git a/Getting Started/Docker/Debian/Edit Excel/Edit Excel.sln b/Getting Started/Docker/Debian/Edit Excel/Edit Excel.sln new file mode 100644 index 00000000..661c649d --- /dev/null +++ b/Getting Started/Docker/Debian/Edit Excel/Edit Excel.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Edit Excel", "Edit Excel\Edit Excel.csproj", "{99505F2C-BF30-4FD4-BB49-03E0A1678C15}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {99505F2C-BF30-4FD4-BB49-03E0A1678C15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {99505F2C-BF30-4FD4-BB49-03E0A1678C15}.Debug|Any CPU.Build.0 = Debug|Any CPU + {99505F2C-BF30-4FD4-BB49-03E0A1678C15}.Release|Any CPU.ActiveCfg = Release|Any CPU + {99505F2C-BF30-4FD4-BB49-03E0A1678C15}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {16C05A96-030D-4F23-A471-4CB96094FE98} + EndGlobalSection +EndGlobal diff --git a/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Data/InputTemplate.xlsx b/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Data/InputTemplate.xlsx new file mode 100644 index 00000000..8be31fc9 Binary files /dev/null and b/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Data/InputTemplate.xlsx differ diff --git a/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Dockerfile b/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Dockerfile new file mode 100644 index 00000000..81c16828 --- /dev/null +++ b/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Dockerfile @@ -0,0 +1,21 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:3.1-buster-slim AS base +RUN apt-get update -y && apt-get install fontconfig -y +WORKDIR /app + +FROM mcr.microsoft.com/dotnet/sdk:3.1-buster-slim AS build +WORKDIR /src +COPY ["Edit Excel.csproj", "."] +RUN dotnet restore "./Edit Excel.csproj" +COPY . . +WORKDIR "/src/." +RUN dotnet build "Edit Excel.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "Edit Excel.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Edit Excel.dll"] \ No newline at end of file diff --git a/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Edit Excel.csproj b/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Edit Excel.csproj new file mode 100644 index 00000000..eed1ecb9 --- /dev/null +++ b/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Edit Excel.csproj @@ -0,0 +1,15 @@ + + + + Exe + netcoreapp3.1 + Edit_Excel + Linux + + + + + + + + diff --git a/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Edit Excel.csproj.user b/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Edit Excel.csproj.user new file mode 100644 index 00000000..e681dafe --- /dev/null +++ b/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Edit Excel.csproj.user @@ -0,0 +1,6 @@ + + + + Docker + + \ No newline at end of file diff --git a/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Program.cs b/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Program.cs new file mode 100644 index 00000000..b4831cb1 --- /dev/null +++ b/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Program.cs @@ -0,0 +1,40 @@ +using Syncfusion.XlsIO; +using System; +using System.IO; +using static System.Net.Mime.MediaTypeNames; + +namespace Edit_Excel +{ + internal class Program + { + static void Main(string[] args) + { + using (ExcelEngine excelEngine = new ExcelEngine()) + { + + //Instantiate the Excel application object + IApplication application = excelEngine.Excel; + + //Assigns default application version + application.DefaultVersion = ExcelVersion.Xlsx; + + //A existing workbook is opened. + FileStream sampleFile = new FileStream("Data/InputTemplate.xlsx", FileMode.Open); + IWorkbook workbook = application.Workbooks.Open(sampleFile); + + //Access first worksheet from the workbook. + IWorksheet worksheet = workbook.Worksheets[0]; + + //Set Text in cell A3. + worksheet.Range["A3"].Text = "Hello World"; + + //Saving the workbook as stream + FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); + workbook.SaveAs(stream); + + //Dispose the stream + stream.Dispose(); + } + } + } +} diff --git a/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Properties/launchSettings.json b/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Properties/launchSettings.json new file mode 100644 index 00000000..5502a70e --- /dev/null +++ b/Getting Started/Docker/Debian/Edit Excel/Edit Excel/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "Edit Excel": { + "commandName": "Project" + }, + "Docker": { + "commandName": "Docker" + } + } +} \ No newline at end of file diff --git a/Getting Started/Docker/RHEL/Create Excel/Create Excel.sln b/Getting Started/Docker/RHEL/Create Excel/Create Excel.sln new file mode 100644 index 00000000..97aa2f67 --- /dev/null +++ b/Getting Started/Docker/RHEL/Create Excel/Create Excel.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create Excel", "Create Excel\Create Excel.csproj", "{2F3C94BA-EBCF-4F0E-A3A6-DE5B1A974C17}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2F3C94BA-EBCF-4F0E-A3A6-DE5B1A974C17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F3C94BA-EBCF-4F0E-A3A6-DE5B1A974C17}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F3C94BA-EBCF-4F0E-A3A6-DE5B1A974C17}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F3C94BA-EBCF-4F0E-A3A6-DE5B1A974C17}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D5E3DA1C-0C5A-4569-B3C3-03C8DC23B294} + EndGlobalSection +EndGlobal diff --git a/Getting Started/Docker/RHEL/Create Excel/Create Excel/Create Excel.csproj b/Getting Started/Docker/RHEL/Create Excel/Create Excel/Create Excel.csproj new file mode 100644 index 00000000..abdd97ce --- /dev/null +++ b/Getting Started/Docker/RHEL/Create Excel/Create Excel/Create Excel.csproj @@ -0,0 +1,15 @@ + + + + Exe + netcoreapp3.1 + Create_Excel + Linux + + + + + + + + diff --git a/Getting Started/Docker/RHEL/Create Excel/Create Excel/Create Excel.csproj.user b/Getting Started/Docker/RHEL/Create Excel/Create Excel/Create Excel.csproj.user new file mode 100644 index 00000000..e681dafe --- /dev/null +++ b/Getting Started/Docker/RHEL/Create Excel/Create Excel/Create Excel.csproj.user @@ -0,0 +1,6 @@ + + + + Docker + + \ No newline at end of file diff --git a/Getting Started/Docker/RHEL/Create Excel/Create Excel/Data/AdventureCycles-Logo.png b/Getting Started/Docker/RHEL/Create Excel/Create Excel/Data/AdventureCycles-Logo.png new file mode 100644 index 00000000..2b6003c2 Binary files /dev/null and b/Getting Started/Docker/RHEL/Create Excel/Create Excel/Data/AdventureCycles-Logo.png differ diff --git a/Getting Started/Docker/RHEL/Create Excel/Create Excel/Dockerfile b/Getting Started/Docker/RHEL/Create Excel/Create Excel/Dockerfile new file mode 100644 index 00000000..aa20a45f --- /dev/null +++ b/Getting Started/Docker/RHEL/Create Excel/Create Excel/Dockerfile @@ -0,0 +1,22 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM registry.access.redhat.com/ubi8/dotnet-31-runtime AS base +USER root +RUN yum -y install fontconfig --disablerepo=epel +WORKDIR / + +FROM registry.access.redhat.com/ubi8/dotnet-31 AS build +WORKDIR /src +COPY ["Create Excel.csproj", ""] +RUN dotnet restore "./Create Excel.csproj" +COPY . . +WORKDIR "/src/." +RUN dotnet build "Create Excel.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "Create Excel.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Create Excel.dll"] \ No newline at end of file diff --git a/Getting Started/Docker/RHEL/Create Excel/Create Excel/Program.cs b/Getting Started/Docker/RHEL/Create Excel/Create Excel/Program.cs new file mode 100644 index 00000000..832bbf73 --- /dev/null +++ b/Getting Started/Docker/RHEL/Create Excel/Create Excel/Program.cs @@ -0,0 +1,189 @@ +using Syncfusion.XlsIO; +using Syncfusion.Drawing; +using System; +using System.IO; + +namespace Create_Excel +{ + internal class Program + { + static void Main(string[] args) + { + //Create an instance of ExcelEngine + using (ExcelEngine excelEngine = new ExcelEngine()) + { + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + + //Create a workbook + IWorkbook workbook = application.Workbooks.Create(1); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Adding a picture + FileStream imageStream = new FileStream("Data/AdventureCycles-Logo.png", FileMode.Open, FileAccess.Read); + IPictureShape shape = worksheet.Pictures.AddPicture(1, 1, imageStream, 20, 20); + + //Disable gridlines in the worksheet + worksheet.IsGridLinesVisible = false; + + //Enter values to the cells from A3 to A5 + worksheet.Range["A3"].Text = "46036 Michigan Ave"; + worksheet.Range["A4"].Text = "Canton, USA"; + worksheet.Range["A5"].Text = "Phone: +1 231-231-2310"; + + //Make the text bold + worksheet.Range["A3:A5"].CellStyle.Font.Bold = true; + + //Merge cells + worksheet.Range["D1:E1"].Merge(); + + //Enter text to the cell D1 and apply formatting. + worksheet.Range["D1"].Text = "INVOICE"; + worksheet.Range["D1"].CellStyle.Font.Bold = true; + worksheet.Range["D1"].CellStyle.Font.RGBColor = Color.FromArgb(42, 118, 189); + worksheet.Range["D1"].CellStyle.Font.Size = 35; + + //Apply alignment in the cell D1 + worksheet.Range["D1"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignRight; + worksheet.Range["D1"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignTop; + + //Enter values to the cells from D5 to E8 + worksheet.Range["D5"].Text = "INVOICE#"; + worksheet.Range["E5"].Text = "DATE"; + worksheet.Range["D6"].Number = 1028; + worksheet.Range["E6"].Value = "12/31/2018"; + worksheet.Range["D7"].Text = "CUSTOMER ID"; + worksheet.Range["E7"].Text = "TERMS"; + worksheet.Range["D8"].Number = 564; + worksheet.Range["E8"].Text = "Due Upon Receipt"; + + //Apply RGB backcolor to the cells from D5 to E8 + worksheet.Range["D5:E5"].CellStyle.Color = Color.FromArgb(42, 118, 189); + worksheet.Range["D7:E7"].CellStyle.Color = Color.FromArgb(42, 118, 189); + + //Apply known colors to the text in cells D5 to E8 + worksheet.Range["D5:E5"].CellStyle.Font.Color = ExcelKnownColors.White; + worksheet.Range["D7:E7"].CellStyle.Font.Color = ExcelKnownColors.White; + + //Make the text as bold from D5 to E8 + worksheet.Range["D5:E8"].CellStyle.Font.Bold = true; + + //Apply alignment to the cells from D5 to E8 + worksheet.Range["D5:E8"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter; + worksheet.Range["D5:E5"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignCenter; + worksheet.Range["D7:E7"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignCenter; + worksheet.Range["D6:E6"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignTop; + + //Enter value and applying formatting in the cell A7 + worksheet.Range["A7"].Text = " BILL TO"; + worksheet.Range["A7"].CellStyle.Color = Color.FromArgb(42, 118, 189); + worksheet.Range["A7"].CellStyle.Font.Bold = true; + worksheet.Range["A7"].CellStyle.Font.Color = ExcelKnownColors.White; + + //Apply alignment + worksheet.Range["A7"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignLeft; + worksheet.Range["A7"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignCenter; + + //Enter values in the cells A8 to A12 + worksheet.Range["A8"].Text = "Steyn"; + worksheet.Range["A9"].Text = "Great Lakes Food Market"; + worksheet.Range["A10"].Text = "20 Whitehall Rd"; + worksheet.Range["A11"].Text = "North Muskegon,USA"; + worksheet.Range["A12"].Text = "+1 231-654-0000"; + + //Create a Hyperlink for e-mail in the cell A13 + IHyperLink hyperlink = worksheet.HyperLinks.Add(worksheet.Range["A13"]); + hyperlink.Type = ExcelHyperLinkType.Url; + hyperlink.Address = "Steyn@greatlakes.com"; + hyperlink.ScreenTip = "Send Mail"; + + //Merge column A and B from row 15 to 22 + worksheet.Range["A15:B15"].Merge(); + worksheet.Range["A16:B16"].Merge(); + worksheet.Range["A17:B17"].Merge(); + worksheet.Range["A18:B18"].Merge(); + worksheet.Range["A19:B19"].Merge(); + worksheet.Range["A20:B20"].Merge(); + worksheet.Range["A21:B21"].Merge(); + worksheet.Range["A22:B22"].Merge(); + + //Enter details of products and prices + worksheet.Range["A15"].Text = " DESCRIPTION"; + worksheet.Range["C15"].Text = "QTY"; + worksheet.Range["D15"].Text = "UNIT PRICE"; + worksheet.Range["E15"].Text = "AMOUNT"; + worksheet.Range["A16"].Text = "Cabrales Cheese"; + worksheet.Range["A17"].Text = "Chocos"; + worksheet.Range["A18"].Text = "Pasta"; + worksheet.Range["A19"].Text = "Cereals"; + worksheet.Range["A20"].Text = "Ice Cream"; + worksheet.Range["C16"].Number = 3; + worksheet.Range["C17"].Number = 2; + worksheet.Range["C18"].Number = 1; + worksheet.Range["C19"].Number = 4; + worksheet.Range["C20"].Number = 3; + worksheet.Range["D16"].Number = 21; + worksheet.Range["D17"].Number = 54; + worksheet.Range["D18"].Number = 10; + worksheet.Range["D19"].Number = 20; + worksheet.Range["D20"].Number = 30; + worksheet.Range["D23"].Text = "Total"; + + //Apply number format + worksheet.Range["D16:E22"].NumberFormat = "$.00"; + worksheet.Range["E23"].NumberFormat = "$.00"; + + //Apply incremental formula for column Amount by multiplying Qty and UnitPrice + application.EnableIncrementalFormula = true; + worksheet.Range["E16:E20"].Formula = "=C16*D16"; + + //Formula for Sum the total + worksheet.Range["E23"].Formula = "=SUM(E16:E22)"; + + //Apply borders + worksheet.Range["A16:E22"].CellStyle.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin; + worksheet.Range["A16:E22"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin; + worksheet.Range["A16:E22"].CellStyle.Borders[ExcelBordersIndex.EdgeTop].Color = ExcelKnownColors.Grey_25_percent; + worksheet.Range["A16:E22"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].Color = ExcelKnownColors.Grey_25_percent; + worksheet.Range["A23:E23"].CellStyle.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin; + worksheet.Range["A23:E23"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin; + worksheet.Range["A23:E23"].CellStyle.Borders[ExcelBordersIndex.EdgeTop].Color = ExcelKnownColors.Black; + worksheet.Range["A23:E23"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].Color = ExcelKnownColors.Black; + + //Apply font setting for cells with product details + worksheet.Range["A3:E23"].CellStyle.Font.FontName = "Arial"; + worksheet.Range["A3:E23"].CellStyle.Font.Size = 10; + worksheet.Range["A15:E15"].CellStyle.Font.Color = ExcelKnownColors.White; + worksheet.Range["A15:E15"].CellStyle.Font.Bold = true; + worksheet.Range["D23:E23"].CellStyle.Font.Bold = true; + + //Apply cell color + worksheet.Range["A15:E15"].CellStyle.Color = Color.FromArgb(42, 118, 189); + + //Apply alignment to cells with product details + worksheet.Range["A15"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignLeft; + worksheet.Range["C15:C22"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter; + worksheet.Range["D15:E15"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter; + + //Apply row height and column width to look good + worksheet.Range["A1"].ColumnWidth = 36; + worksheet.Range["B1"].ColumnWidth = 11; + worksheet.Range["C1"].ColumnWidth = 8; + worksheet.Range["D1:E1"].ColumnWidth = 18; + worksheet.Range["A1"].RowHeight = 47; + worksheet.Range["A2"].RowHeight = 15; + worksheet.Range["A3:A4"].RowHeight = 15; + worksheet.Range["A5"].RowHeight = 18; + worksheet.Range["A6"].RowHeight = 29; + worksheet.Range["A7"].RowHeight = 18; + worksheet.Range["A8"].RowHeight = 15; + worksheet.Range["A9:A14"].RowHeight = 15; + worksheet.Range["A15:A23"].RowHeight = 18; + + //Saving the Excel to the MemoryStream + FileStream outputStream = new FileStream("Output.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite); + workbook.SaveAs(outputStream); + } + } + } +} diff --git a/Getting Started/Docker/RHEL/Create Excel/Create Excel/Properties/launchSettings.json b/Getting Started/Docker/RHEL/Create Excel/Create Excel/Properties/launchSettings.json new file mode 100644 index 00000000..99916c3a --- /dev/null +++ b/Getting Started/Docker/RHEL/Create Excel/Create Excel/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "Create Excel": { + "commandName": "Project" + }, + "Docker": { + "commandName": "Docker" + } + } +} \ No newline at end of file diff --git a/Getting Started/Docker/RHEL/Edit Excel/Edit Excel.sln b/Getting Started/Docker/RHEL/Edit Excel/Edit Excel.sln new file mode 100644 index 00000000..f4da1af9 --- /dev/null +++ b/Getting Started/Docker/RHEL/Edit Excel/Edit Excel.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Edit Excel", "Edit Excel\Edit Excel.csproj", "{6ED35C27-78E4-46C7-A808-3C3DF0EC4F9B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6ED35C27-78E4-46C7-A808-3C3DF0EC4F9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6ED35C27-78E4-46C7-A808-3C3DF0EC4F9B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6ED35C27-78E4-46C7-A808-3C3DF0EC4F9B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6ED35C27-78E4-46C7-A808-3C3DF0EC4F9B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {727A9015-DEB7-4BEF-9A0A-5CC8CFC1A63D} + EndGlobalSection +EndGlobal diff --git a/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Data/InputTemplate.xlsx b/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Data/InputTemplate.xlsx new file mode 100644 index 00000000..8be31fc9 Binary files /dev/null and b/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Data/InputTemplate.xlsx differ diff --git a/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Dockerfile b/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Dockerfile new file mode 100644 index 00000000..56799a69 --- /dev/null +++ b/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Dockerfile @@ -0,0 +1,22 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM registry.access.redhat.com/ubi8/dotnet-31-runtime AS base +USER root +RUN yum -y install fontconfig --disablerepo=epel +WORKDIR / + +FROM registry.access.redhat.com/ubi8/dotnet-31 AS build +WORKDIR /src +COPY ["Edit Excel.csproj", ""] +RUN dotnet restore "./Edit Excel.csproj" +COPY . . +WORKDIR "/src/." +RUN dotnet build "Edit Excel.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "Edit Excel.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Edit Excel.dll"] \ No newline at end of file diff --git a/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Edit Excel.csproj b/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Edit Excel.csproj new file mode 100644 index 00000000..eed1ecb9 --- /dev/null +++ b/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Edit Excel.csproj @@ -0,0 +1,15 @@ + + + + Exe + netcoreapp3.1 + Edit_Excel + Linux + + + + + + + + diff --git a/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Edit Excel.csproj.user b/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Edit Excel.csproj.user new file mode 100644 index 00000000..e681dafe --- /dev/null +++ b/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Edit Excel.csproj.user @@ -0,0 +1,6 @@ + + + + Docker + + \ No newline at end of file diff --git a/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Program.cs b/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Program.cs new file mode 100644 index 00000000..b4831cb1 --- /dev/null +++ b/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Program.cs @@ -0,0 +1,40 @@ +using Syncfusion.XlsIO; +using System; +using System.IO; +using static System.Net.Mime.MediaTypeNames; + +namespace Edit_Excel +{ + internal class Program + { + static void Main(string[] args) + { + using (ExcelEngine excelEngine = new ExcelEngine()) + { + + //Instantiate the Excel application object + IApplication application = excelEngine.Excel; + + //Assigns default application version + application.DefaultVersion = ExcelVersion.Xlsx; + + //A existing workbook is opened. + FileStream sampleFile = new FileStream("Data/InputTemplate.xlsx", FileMode.Open); + IWorkbook workbook = application.Workbooks.Open(sampleFile); + + //Access first worksheet from the workbook. + IWorksheet worksheet = workbook.Worksheets[0]; + + //Set Text in cell A3. + worksheet.Range["A3"].Text = "Hello World"; + + //Saving the workbook as stream + FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); + workbook.SaveAs(stream); + + //Dispose the stream + stream.Dispose(); + } + } + } +} diff --git a/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Properties/launchSettings.json b/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Properties/launchSettings.json new file mode 100644 index 00000000..5502a70e --- /dev/null +++ b/Getting Started/Docker/RHEL/Edit Excel/Edit Excel/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "Edit Excel": { + "commandName": "Project" + }, + "Docker": { + "commandName": "Docker" + } + } +} \ No newline at end of file diff --git a/Getting Started/Docker/Ubuntu/Create Excel/Create Excel.sln b/Getting Started/Docker/Ubuntu/Create Excel/Create Excel.sln new file mode 100644 index 00000000..2fc5a213 --- /dev/null +++ b/Getting Started/Docker/Ubuntu/Create Excel/Create Excel.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create Excel", "Create Excel\Create Excel.csproj", "{65B5E1AE-9290-45D8-8ACB-56E6A798AA5B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {65B5E1AE-9290-45D8-8ACB-56E6A798AA5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {65B5E1AE-9290-45D8-8ACB-56E6A798AA5B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {65B5E1AE-9290-45D8-8ACB-56E6A798AA5B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {65B5E1AE-9290-45D8-8ACB-56E6A798AA5B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {14416922-2B48-4AF9-891A-96D83ECD4035} + EndGlobalSection +EndGlobal diff --git a/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Create Excel.csproj b/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Create Excel.csproj new file mode 100644 index 00000000..9d99deac --- /dev/null +++ b/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Create Excel.csproj @@ -0,0 +1,15 @@ + + + + Exe + netcoreapp3.1 + Create_Excel + Linux + + + + + + + + diff --git a/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Create Excel.csproj.user b/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Create Excel.csproj.user new file mode 100644 index 00000000..e681dafe --- /dev/null +++ b/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Create Excel.csproj.user @@ -0,0 +1,6 @@ + + + + Docker + + \ No newline at end of file diff --git a/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Data/AdventureCycles-Logo.png b/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Data/AdventureCycles-Logo.png new file mode 100644 index 00000000..2b6003c2 Binary files /dev/null and b/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Data/AdventureCycles-Logo.png differ diff --git a/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Dockerfile b/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Dockerfile new file mode 100644 index 00000000..10db65b9 --- /dev/null +++ b/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Dockerfile @@ -0,0 +1,21 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/core/runtime:3.1-bionic AS base +RUN apt-get update -y && apt-get install fontconfig -y +WORKDIR /app + +FROM mcr.microsoft.com/dotnet/core/sdk:3.1-bionic AS build +WORKDIR /src +COPY ["Create Excel/Create Excel.csproj", "Create Excel/"] +RUN dotnet restore "Create Excel/Create Excel.csproj +COPY . . +WORKDIR "/src/Create Excel" +RUN dotnet build "Create Excel.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "Create Excel.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Create Excel.dll"] \ No newline at end of file diff --git a/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Program.cs b/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Program.cs new file mode 100644 index 00000000..832bbf73 --- /dev/null +++ b/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Program.cs @@ -0,0 +1,189 @@ +using Syncfusion.XlsIO; +using Syncfusion.Drawing; +using System; +using System.IO; + +namespace Create_Excel +{ + internal class Program + { + static void Main(string[] args) + { + //Create an instance of ExcelEngine + using (ExcelEngine excelEngine = new ExcelEngine()) + { + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + + //Create a workbook + IWorkbook workbook = application.Workbooks.Create(1); + IWorksheet worksheet = workbook.Worksheets[0]; + + //Adding a picture + FileStream imageStream = new FileStream("Data/AdventureCycles-Logo.png", FileMode.Open, FileAccess.Read); + IPictureShape shape = worksheet.Pictures.AddPicture(1, 1, imageStream, 20, 20); + + //Disable gridlines in the worksheet + worksheet.IsGridLinesVisible = false; + + //Enter values to the cells from A3 to A5 + worksheet.Range["A3"].Text = "46036 Michigan Ave"; + worksheet.Range["A4"].Text = "Canton, USA"; + worksheet.Range["A5"].Text = "Phone: +1 231-231-2310"; + + //Make the text bold + worksheet.Range["A3:A5"].CellStyle.Font.Bold = true; + + //Merge cells + worksheet.Range["D1:E1"].Merge(); + + //Enter text to the cell D1 and apply formatting. + worksheet.Range["D1"].Text = "INVOICE"; + worksheet.Range["D1"].CellStyle.Font.Bold = true; + worksheet.Range["D1"].CellStyle.Font.RGBColor = Color.FromArgb(42, 118, 189); + worksheet.Range["D1"].CellStyle.Font.Size = 35; + + //Apply alignment in the cell D1 + worksheet.Range["D1"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignRight; + worksheet.Range["D1"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignTop; + + //Enter values to the cells from D5 to E8 + worksheet.Range["D5"].Text = "INVOICE#"; + worksheet.Range["E5"].Text = "DATE"; + worksheet.Range["D6"].Number = 1028; + worksheet.Range["E6"].Value = "12/31/2018"; + worksheet.Range["D7"].Text = "CUSTOMER ID"; + worksheet.Range["E7"].Text = "TERMS"; + worksheet.Range["D8"].Number = 564; + worksheet.Range["E8"].Text = "Due Upon Receipt"; + + //Apply RGB backcolor to the cells from D5 to E8 + worksheet.Range["D5:E5"].CellStyle.Color = Color.FromArgb(42, 118, 189); + worksheet.Range["D7:E7"].CellStyle.Color = Color.FromArgb(42, 118, 189); + + //Apply known colors to the text in cells D5 to E8 + worksheet.Range["D5:E5"].CellStyle.Font.Color = ExcelKnownColors.White; + worksheet.Range["D7:E7"].CellStyle.Font.Color = ExcelKnownColors.White; + + //Make the text as bold from D5 to E8 + worksheet.Range["D5:E8"].CellStyle.Font.Bold = true; + + //Apply alignment to the cells from D5 to E8 + worksheet.Range["D5:E8"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter; + worksheet.Range["D5:E5"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignCenter; + worksheet.Range["D7:E7"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignCenter; + worksheet.Range["D6:E6"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignTop; + + //Enter value and applying formatting in the cell A7 + worksheet.Range["A7"].Text = " BILL TO"; + worksheet.Range["A7"].CellStyle.Color = Color.FromArgb(42, 118, 189); + worksheet.Range["A7"].CellStyle.Font.Bold = true; + worksheet.Range["A7"].CellStyle.Font.Color = ExcelKnownColors.White; + + //Apply alignment + worksheet.Range["A7"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignLeft; + worksheet.Range["A7"].CellStyle.VerticalAlignment = ExcelVAlign.VAlignCenter; + + //Enter values in the cells A8 to A12 + worksheet.Range["A8"].Text = "Steyn"; + worksheet.Range["A9"].Text = "Great Lakes Food Market"; + worksheet.Range["A10"].Text = "20 Whitehall Rd"; + worksheet.Range["A11"].Text = "North Muskegon,USA"; + worksheet.Range["A12"].Text = "+1 231-654-0000"; + + //Create a Hyperlink for e-mail in the cell A13 + IHyperLink hyperlink = worksheet.HyperLinks.Add(worksheet.Range["A13"]); + hyperlink.Type = ExcelHyperLinkType.Url; + hyperlink.Address = "Steyn@greatlakes.com"; + hyperlink.ScreenTip = "Send Mail"; + + //Merge column A and B from row 15 to 22 + worksheet.Range["A15:B15"].Merge(); + worksheet.Range["A16:B16"].Merge(); + worksheet.Range["A17:B17"].Merge(); + worksheet.Range["A18:B18"].Merge(); + worksheet.Range["A19:B19"].Merge(); + worksheet.Range["A20:B20"].Merge(); + worksheet.Range["A21:B21"].Merge(); + worksheet.Range["A22:B22"].Merge(); + + //Enter details of products and prices + worksheet.Range["A15"].Text = " DESCRIPTION"; + worksheet.Range["C15"].Text = "QTY"; + worksheet.Range["D15"].Text = "UNIT PRICE"; + worksheet.Range["E15"].Text = "AMOUNT"; + worksheet.Range["A16"].Text = "Cabrales Cheese"; + worksheet.Range["A17"].Text = "Chocos"; + worksheet.Range["A18"].Text = "Pasta"; + worksheet.Range["A19"].Text = "Cereals"; + worksheet.Range["A20"].Text = "Ice Cream"; + worksheet.Range["C16"].Number = 3; + worksheet.Range["C17"].Number = 2; + worksheet.Range["C18"].Number = 1; + worksheet.Range["C19"].Number = 4; + worksheet.Range["C20"].Number = 3; + worksheet.Range["D16"].Number = 21; + worksheet.Range["D17"].Number = 54; + worksheet.Range["D18"].Number = 10; + worksheet.Range["D19"].Number = 20; + worksheet.Range["D20"].Number = 30; + worksheet.Range["D23"].Text = "Total"; + + //Apply number format + worksheet.Range["D16:E22"].NumberFormat = "$.00"; + worksheet.Range["E23"].NumberFormat = "$.00"; + + //Apply incremental formula for column Amount by multiplying Qty and UnitPrice + application.EnableIncrementalFormula = true; + worksheet.Range["E16:E20"].Formula = "=C16*D16"; + + //Formula for Sum the total + worksheet.Range["E23"].Formula = "=SUM(E16:E22)"; + + //Apply borders + worksheet.Range["A16:E22"].CellStyle.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin; + worksheet.Range["A16:E22"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin; + worksheet.Range["A16:E22"].CellStyle.Borders[ExcelBordersIndex.EdgeTop].Color = ExcelKnownColors.Grey_25_percent; + worksheet.Range["A16:E22"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].Color = ExcelKnownColors.Grey_25_percent; + worksheet.Range["A23:E23"].CellStyle.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin; + worksheet.Range["A23:E23"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin; + worksheet.Range["A23:E23"].CellStyle.Borders[ExcelBordersIndex.EdgeTop].Color = ExcelKnownColors.Black; + worksheet.Range["A23:E23"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].Color = ExcelKnownColors.Black; + + //Apply font setting for cells with product details + worksheet.Range["A3:E23"].CellStyle.Font.FontName = "Arial"; + worksheet.Range["A3:E23"].CellStyle.Font.Size = 10; + worksheet.Range["A15:E15"].CellStyle.Font.Color = ExcelKnownColors.White; + worksheet.Range["A15:E15"].CellStyle.Font.Bold = true; + worksheet.Range["D23:E23"].CellStyle.Font.Bold = true; + + //Apply cell color + worksheet.Range["A15:E15"].CellStyle.Color = Color.FromArgb(42, 118, 189); + + //Apply alignment to cells with product details + worksheet.Range["A15"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignLeft; + worksheet.Range["C15:C22"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter; + worksheet.Range["D15:E15"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter; + + //Apply row height and column width to look good + worksheet.Range["A1"].ColumnWidth = 36; + worksheet.Range["B1"].ColumnWidth = 11; + worksheet.Range["C1"].ColumnWidth = 8; + worksheet.Range["D1:E1"].ColumnWidth = 18; + worksheet.Range["A1"].RowHeight = 47; + worksheet.Range["A2"].RowHeight = 15; + worksheet.Range["A3:A4"].RowHeight = 15; + worksheet.Range["A5"].RowHeight = 18; + worksheet.Range["A6"].RowHeight = 29; + worksheet.Range["A7"].RowHeight = 18; + worksheet.Range["A8"].RowHeight = 15; + worksheet.Range["A9:A14"].RowHeight = 15; + worksheet.Range["A15:A23"].RowHeight = 18; + + //Saving the Excel to the MemoryStream + FileStream outputStream = new FileStream("Output.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite); + workbook.SaveAs(outputStream); + } + } + } +} diff --git a/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Properties/launchSettings.json b/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Properties/launchSettings.json new file mode 100644 index 00000000..99916c3a --- /dev/null +++ b/Getting Started/Docker/Ubuntu/Create Excel/Create Excel/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "Create Excel": { + "commandName": "Project" + }, + "Docker": { + "commandName": "Docker" + } + } +} \ No newline at end of file diff --git a/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel.sln b/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel.sln new file mode 100644 index 00000000..3b704f47 --- /dev/null +++ b/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Edit Excel", "Edit Excel\Edit Excel.csproj", "{AAEFAA0C-F2B9-4649-9A1D-DDC5D38CB402}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AAEFAA0C-F2B9-4649-9A1D-DDC5D38CB402}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AAEFAA0C-F2B9-4649-9A1D-DDC5D38CB402}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AAEFAA0C-F2B9-4649-9A1D-DDC5D38CB402}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AAEFAA0C-F2B9-4649-9A1D-DDC5D38CB402}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CECC879E-7974-4FDE-A000-831D3FE6952C} + EndGlobalSection +EndGlobal diff --git a/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Data/InputTemplate.xlsx b/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Data/InputTemplate.xlsx new file mode 100644 index 00000000..8be31fc9 Binary files /dev/null and b/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Data/InputTemplate.xlsx differ diff --git a/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Dockerfile b/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Dockerfile new file mode 100644 index 00000000..fd6e7b01 --- /dev/null +++ b/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Dockerfile @@ -0,0 +1,21 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/core/runtime:3.1-bionic AS base +RUN apt-get update -y && apt-get install fontconfig -y +WORKDIR /app + +FROM mcr.microsoft.com/dotnet/core/sdk:3.1-bionic AS build +WORKDIR /src +COPY ["Edit Excel.csproj", "."] +RUN dotnet restore "./Edit Excel.csproj" +COPY . . +WORKDIR "/src/Edit Excel" +RUN dotnet build "Edit Excel.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "Edit Excel.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Edit Excel.dll"] \ No newline at end of file diff --git a/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Edit Excel.csproj b/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Edit Excel.csproj new file mode 100644 index 00000000..eed1ecb9 --- /dev/null +++ b/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Edit Excel.csproj @@ -0,0 +1,15 @@ + + + + Exe + netcoreapp3.1 + Edit_Excel + Linux + + + + + + + + diff --git a/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Edit Excel.csproj.user b/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Edit Excel.csproj.user new file mode 100644 index 00000000..e681dafe --- /dev/null +++ b/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Edit Excel.csproj.user @@ -0,0 +1,6 @@ + + + + Docker + + \ No newline at end of file diff --git a/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Program.cs b/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Program.cs new file mode 100644 index 00000000..b0962bc0 --- /dev/null +++ b/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Program.cs @@ -0,0 +1,39 @@ +using Syncfusion.XlsIO; +using System; +using System.IO; + +namespace Edit_Excel +{ + internal class Program + { + static void Main(string[] args) + { + using (ExcelEngine excelEngine = new ExcelEngine()) + { + + //Instantiate the Excel application object + IApplication application = excelEngine.Excel; + + //Assigns default application version + application.DefaultVersion = ExcelVersion.Xlsx; + + //A existing workbook is opened. + FileStream sampleFile = new FileStream("Data/InputTemplate.xlsx", FileMode.Open); + IWorkbook workbook = application.Workbooks.Open(sampleFile); + + //Access first worksheet from the workbook. + IWorksheet worksheet = workbook.Worksheets[0]; + + //Set Text in cell A3. + worksheet.Range["A3"].Text = "Hello World"; + + //Saving the workbook as stream + FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); + workbook.SaveAs(stream); + + //Dispose the stream + stream.Dispose(); + } + } + } +} diff --git a/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Properties/launchSettings.json b/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Properties/launchSettings.json new file mode 100644 index 00000000..5502a70e --- /dev/null +++ b/Getting Started/Docker/Ubuntu/Edit Excel/Edit Excel/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "Edit Excel": { + "commandName": "Project" + }, + "Docker": { + "commandName": "Docker" + } + } +} \ No newline at end of file