Untitled
unknown
plain_text
a year ago
3.2 kB
16
Indexable
try { var workbook = new XLWorkbook(); var worksheet = workbook.Worksheets.Add("Cấu hình tin đăng"); var col1 = worksheet.Column("A"); col1.SetDataType(XLDataType.Text); col1.Width = 25; var col2 = worksheet.Column("B"); col2.SetDataType(XLDataType.Text); col2.Width = 55; var col3 = worksheet.Column("C"); col3.SetDataType(XLDataType.Number); col3.Width = 25; var col4 = worksheet.Column("D"); col4.SetDataType(XLDataType.Text); col4.Width = 55; worksheet.Cell("A1").SetValue("ID"); worksheet.Cell("B1").SetValue("Name"); worksheet.Cell("C1").SetValue("Thành viên"); worksheet.Cell("D1").SetValue("Link"); worksheet.Cell("E1").SetValue("Status"); int i = 1; List<GridRow> listgroup = Data_GetIDGroupPage.Finds(y => y.Count >= num).ToList(); if (!string.IsNullOrEmpty(text)) listgroup = listgroup.Finds(x => x.Status.IsContains(text)); List<string> list = new List<string>(); foreach (GridRow post in listgroup) { if (list.IContains(post.GroupID)) continue; else list.Add(post.GroupID); i++; try { worksheet.Cell("A" + i).SetValue(post.GroupID); } catch { } try { worksheet.Cell("B" + i).SetValue(post.GroupName); } catch { } try { worksheet.Cell("C" + i).SetValue(post.Count); } catch { } try { worksheet.Cell("D" + i).SetValue(post.Status1); } catch { } try { worksheet.Cell("E" + i).SetValue(post.Status); } catch { } } workbook.SaveAs(file.FileName); workbook.Dispose(); MessageBoxShow("Lưu thành công"); } catch (Exception ex) { MessageBoxShow("Lưu thất bại : \n" + ex.ToString()); }
Editor is loading...
Leave a Comment