Exemplo n.º 1
0
        public override DownloadableGrades Export(DataTable Grades)
        {
            var TempPath = System.IO.Path.GetTempFileName() + Guid.NewGuid().ToString() + ".docx";;

            ComponentInfo.SetLicense("FREE-LIMITED-KEY");
            var doc = new DocumentModel();

            foreach (DataRow row in Grades.Rows)
            {
                List <string> items = new List <string>();
                foreach (DataColumn col in Grades.Columns)
                {
                    items.Add(row[col.ColumnName].ToString());
                }
                string Line = string.Join(",", items.ToArray());
                doc.Sections.Add(new Section(doc, new Paragraph(doc, Line)));
            }
            doc.Save(TempPath);
            DownloadableGrades DGrades = new DownloadableGrades();


            DGrades.FileName = "grades.docx";
            DGrades.Data     = File.ReadAllBytes(TempPath);
            return(DGrades);
        }
Exemplo n.º 2
0
        public override DownloadableGrades Export(DataTable Grades)
        {
            var          TempPath = System.IO.Path.GetTempFileName();
            StreamWriter writer   = new StreamWriter(TempPath);

            foreach (DataRow row in Grades.Rows)
            {
                List <string> items = new List <string>();
                foreach (DataColumn col in Grades.Columns)
                {
                    items.Add(row[col.ColumnName].ToString());
                }
                string Line = string.Join(",", items.ToArray());
                writer.Write(Line);
                writer.WriteLine();
            }
            writer.Close();

            DownloadableGrades DGrades = new DownloadableGrades();


            DGrades.FileName = "grades.txt";
            DGrades.Data     = File.ReadAllBytes(TempPath);
            writer.Dispose();
            return(DGrades);
        }