// GET: category public ActionResult Index(int?id) { int page; if (id != null) { page = id.Value; } else { page = 0; } pv.product = pm.read().Skip(page).Take(10).ToList();//.Skip(page).ToList(); pv.pagelist = pv.product.Count() / 10; return(View(pv)); }
public ActionResult Index() { homeview.homeproduct = product.read(); homeview.homecategoriy = category.read(); homeview.homemenu = menu.read(); return(View(homeview)); }
public static void FillDraftAndCopyToFinal(IWorkbook _workbook, ISheet _sheet, string _title, MemoryStream sss)//IEnumerable<T> list)//verilen class'a göre listeleme yapması için IEnumerable kullanıcam ama kesin depil { IWorkbook workbook = _workbook; ISheet sheet1 = _sheet; productmanager pm = new productmanager(); var newFile = @"C:\Users\göksel\Downloads\newboo2k122sonis222288822123.core.xlsx"; //using(var fs = new FileStream(newFile, FileMode.Create, FileAccess.Write)) using (var fs = new MemoryStream()) { var style = workbook.CreateCellStyle(); style.FillForegroundColor = HSSFColor.Blue.Index2; style.Alignment = HorizontalAlignment.Center; style.VerticalAlignment = VerticalAlignment.Center; style.FillPattern = FillPattern.SolidForeground; sheet1.AddMergedRegion(new CellRangeAddress(0, 0, 0, 10)); var rowIndex = 0; var row = sheet1.CreateRow(rowIndex).CreateCell(0); row.CellStyle = style; row.SetCellValue(_title); rowIndex++; foreach (var item in pm.read()) { var row1 = sheet1.CreateRow(rowIndex); row1.CreateCell(0).SetCellValue(item.product_name); sheet1.AutoSizeColumn(0); row1.CreateCell(1).SetCellValue(item.cargo.cargo_company); sheet1.AutoSizeColumn(1); row1.CreateCell(2).SetCellValue(item.category.category_name); sheet1.AutoSizeColumn(2); row1.CreateCell(3).SetCellValue(item.cargo_type.cargo_type1); sheet1.AutoSizeColumn(3); row1.CreateCell(4).SetCellValue(item.product_content); sheet1.AutoSizeColumn(4); row1.CreateCell(5).SetCellValue(item.product_add_time.ToString()); sheet1.AutoSizeColumn(5); row1.CreateCell(6).SetCellValue(item.product_price.ToString()); sheet1.AutoSizeColumn(6); row1.CreateCell(7).SetCellValue(item.product_quantity.ToString()); sheet1.AutoSizeColumn(7); row1.CreateCell(8).SetCellValue(item.prouct_image_path); sheet1.AutoSizeColumn(8); row1.CreateCell(9).SetCellValue(item.repository.repository_name); sheet1.AutoSizeColumn(9); rowIndex++; } workbook.Write(fs); } }
public FileResult excel() { IWorkbook workbook = new HSSFWorkbook(); //döküman ISheet sheet1 = workbook.CreateSheet("product 12"); //sayfa productmanager pm = new productmanager(); // var style = workbook.CreateCellStyle(); //sitil dosyası style.FillForegroundColor = HSSFColor.Blue.Index2; //renk style.Alignment = HorizontalAlignment.Center; // metin hizalama style.VerticalAlignment = VerticalAlignment.Center; //metin hzalama style.FillPattern = FillPattern.SolidForeground; // renk doldurma sheet1.AddMergedRegion(new CellRangeAddress(0, 1, 0, 9)); //birleştirme var rowIndex = 0; var row = sheet1.CreateRow(rowIndex).CreateCell(0); row.CellStyle = style; row.SetCellValue("deneme son vol:3"); rowIndex += 2; foreach (var item in pm.read()) { var row1 = sheet1.CreateRow(rowIndex); row1.CreateCell(0).SetCellValue(item.product_name); //hücre değerleri sheet1.AutoSizeColumn(0); // hücre veriye göre boyutlandırma row1.CreateCell(1).SetCellValue(item.cargo.cargo_company); sheet1.AutoSizeColumn(1); row1.CreateCell(2).SetCellValue(item.category.category_name); sheet1.AutoSizeColumn(8); row1.CreateCell(3).SetCellValue(item.cargo_type.cargo_type1); sheet1.AutoSizeColumn(2); row1.CreateCell(4).SetCellValue(item.product_content); sheet1.AutoSizeColumn(3); row1.CreateCell(5).SetCellValue(item.product_add_time.ToString()); sheet1.AutoSizeColumn(4); row1.CreateCell(6).SetCellValue(item.product_price.ToString()); sheet1.AutoSizeColumn(5); row1.CreateCell(7).SetCellValue(item.product_quantity.ToString()); sheet1.AutoSizeColumn(6); row1.CreateCell(8).SetCellValue(item.prouct_image_path); sheet1.AutoSizeColumn(7); row1.CreateCell(9).SetCellValue(item.repository.repository_name); sheet1.AutoSizeColumn(9); rowIndex++; } var stream = new MemoryStream(); workbook.Write(stream); return(File(new MemoryStream(stream.GetBuffer()), "application/vdn.ms-excel", "producttable.xls")); }