BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
public void ExcelExportInvoices() { ExcelExport exp = new ExcelExport(); Invoices model = new Invoices(); string gridModel = System.Web.HttpContext.Current.Request.Params["GridModel"]; GridProperties obj = ConvertGridObject(gridModel); var DataSource = model.getOpenInvoices().ToList(); string nombre = "CxC_" + model.getCompanyNamebyId(empresa); string targetFolder = HttpContext.Server.MapPath("") + "\\Repositorio\\" + User.Identity.Name.ToString() + "\\" ; AutoFormat auto = new AutoFormat(); GridExtensions ext = new GridExtensions(); ext.SetTheme(auto, "default-theme"); auto.FontFamily = "Arial Narrow"; auto.ContentFontSize = 8; auto.HeaderFontSize = 12; auto.GHeaderBgColor = Color.Crimson; obj.AutoFormat = auto; IWorkbook book = exp.Export(obj, DataSource, "Export.xlsx", ExcelVersion.Excel2013, false, false, "default-theme", true); book.ActiveSheet.Range[2, 8, count, 8].HorizontalAlignment = ExcelHAlign.HAlignRight; book.ActiveSheet.Range[1, 8, count, 8].NumberFormat = "_($* #,##0.00_)"; book.ActiveSheet.Range[1, 8, count, 8].AutofitColumns(); book.ActiveSheet.Range[2, 10, count, 10].HorizontalAlignment = ExcelHAlign.HAlignRight; book.ActiveSheet.Range[1, 10, count, 10].NumberFormat = "_($* #,##0.00_)"; book.ActiveSheet.Range[1, 10, count, 10].AutofitColumns(); book.ActiveSheet.Range[2, 11, count, 11].HorizontalAlignment = ExcelHAlign.HAlignRight; book.ActiveSheet.Range[1, 11, count, 11].NumberFormat = "_($* #,##0.00_)"; book.ActiveSheet.Range[1, 11, count, 11].AutofitColumns(); //When I do this, the file is downloaded to my personal computer but not in the targetFolder book.SaveAs(targetFolder + + nombre + ".xlsx", ExcelSaveType.SaveAsXLS, System.Web.HttpContext.Current.Response); // If I tried this other piece of code, the file is stored in the targetFolder, but the cells does not have the format. // string targetFolder = HttpContext.Server.MapPath("") + "\\Repositorio\\" + User.Identity.Name.ToString() + "\\"; // exp.Export(obj, DataSource, fileName, ExcelVersion.Excel2010, false, false, "flat-saffron", true, targetFolder); } |
public void ExportToExcel(string GridModel) { ------------------------------- auto.FontFamily = "Arial Narrow"; auto.ContentFontSize = 8; auto.HeaderFontSize = 12; auto.GHeaderBgColor = Color.Crimson; obj.AutoFormat = auto; obj.ServerExcelRowInfo = querycell; var destination = Server.MapPath("~/App_Data"); exp.Export(obj, ds, "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron", true, destination); } ------------------------------------------------- public void querycell(object sender) { var data = (IRange)sender; if (data.Column == 4 && (data.Row >= 2 && data.Row < 6) ) { data.HorizontalAlignment = ExcelHAlign.HAlignLeft; data.NumberFormat = "#,##0.00"; } } |
book.SaveAs(targetFolder + + nombre + ".xlsx"); |