Esempio n. 1
0
        public ActionResult ExportExcel()
        {
            string b = Request["me"].ToString();

            RKLib.ExportData.Export obj = new RKLib.ExportData.Export("Web");


            System.Net.WebClient client = new System.Net.WebClient();

            //client.Encoding = System.Text.Encoding.UTF8;
            var doc = new HtmlAgilityPack.HtmlDocument();

            //string str = this.TextBox1.Text;
            //string b = HiddenField1.Value;
            doc.LoadHtml(b);

            //doc.LoadHtml(b);

            var nodesT = doc.DocumentNode.SelectNodes("//table/tr");

            var table = new System.Data.DataTable("MyTable");

            var headers = nodesT[0]
                          .Elements("th")
                          .Select(th => th.InnerText.Trim());

            foreach (var header in headers)
            {
                table.Columns.Add(header);
            }

            var rows = nodesT.Skip(1).Select(tr => tr
                                             .Elements("td")
                                             .Select(td => td.InnerText.Trim())
                                             .ToArray());

            foreach (var row in rows)
            {
                table.Rows.Add(row);
            }
            Response.ContentEncoding = System.Text.Encoding.Unicode;
            Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble());


            obj.ExportDetails(table, RKLib.ExportData.Export.ExportFormat.Excel, "Mahsa");
            return(RedirectToAction("View"));
        }
        private void btnExport1_Click(object sender, System.EventArgs e)
        {
            // Export all the details
            try
            {
                // Get the datatable to export
                DataTable dtEmployee = ((DataSet)Session["dsEmployee"]).Tables["Employee"].Copy();

                // Export all the details to CSV
                RKLib.ExportData.Export objExport = new RKLib.ExportData.Export();
                objExport.ExportDetails(dtEmployee, Export.ExportFormat.CSV, "EmployeesInfo1");
            }
            catch (Exception Ex)
            {
                lblError.Text = Ex.Message;
            }
        }
Esempio n. 3
0
        private void btnExportExcel_Click(object sender, System.EventArgs e)
        {
            lblMessage.Text = "";
            DataTable dt = ds.Tables["Table1"].Copy();

            try
            {
                string file = textBoxFolder.Text + "table1.xls";
                RKLib.ExportData.Export objExport = new RKLib.ExportData.Export("Win");
                objExport.ExportDetails(dt, Export.ExportFormat.Excel, file);
                lblMessage.Text = "Successfully exported to " + file;
            }
            catch (Exception Ex)
            {
                lblMessage.Text = Ex.Message;
            }
        }
        private void btnExport1_Click(object sender, System.EventArgs e)
        {
            // Export all the details
            try
            {
                // Get the datatable to export
                DataTable dtEmployee = ((DataSet) Session["dsEmployee"]).Tables["Employee"].Copy();

                // Export all the details to CSV
                RKLib.ExportData.Export objExport = new RKLib.ExportData.Export();
                objExport.ExportDetails(dtEmployee, Export.ExportFormat.CSV, "EmployeesInfo1");
            }
            catch(Exception Ex)
            {
                lblError.Text = Ex.Message;
            }
        }
        private void btnExport2_Click(object sender, System.EventArgs e)
        {
            // Export the details of specified columns
            try
            {
                // Get the datatable to export
                DataTable dtEmployee = ((DataSet)Session["dsEmployee"]).Tables["Employee"].Copy();

                // Specify the column list to export
                int[] iColumns = { 1, 2, 3, 5, 6 };

                // Export the details of specified columns to Excel
                RKLib.ExportData.Export objExport = new RKLib.ExportData.Export();
                objExport.ExportDetails(dtEmployee, iColumns, Export.ExportFormat.Excel, "EmployeesInfo2");
            }
            catch (Exception Ex)
            {
                lblError.Text = Ex.Message;
            }
        }
Esempio n. 6
0
        public static string ExportCsv(DataTable table)
        {
            if (table == null)
            {
                return("");
            }

            if (table.TableName == "")
            {
                table.TableName = "ExportedData";
            }

            string fileName = table.TableName.Replace(" ", "") + ".csv";

            RKLib.ExportData.Export x = new RKLib.ExportData.Export("Win");

            x.ExportDetails(table, RKLib.ExportData.Export.ExportFormat.CSV, fileName);

            return(Ap.FolderAppBin + fileName);
        }
        private void btnExport2_Click(object sender, System.EventArgs e)
        {
            // Export the details of specified columns
            try
            {
                // Get the datatable to export
                DataTable dtEmployee = ((DataSet) Session["dsEmployee"]).Tables["Employee"].Copy();

                // Specify the column list to export
                int[] iColumns = {1,2,3,5,6};

                // Export the details of specified columns to Excel
                RKLib.ExportData.Export objExport = new RKLib.ExportData.Export();
                objExport.ExportDetails(dtEmployee, iColumns, Export.ExportFormat.Excel, "EmployeesInfo2");
            }
            catch(Exception Ex)
            {
                lblError.Text = Ex.Message;
            }
        }
        private void btnExport3_Click(object sender, System.EventArgs e)
        {
            // Export the details of specified columns with specified headers

            try
            {
                // Get the datatable to export
                DataTable dtEmployee = ((DataSet)Session["dsEmployee"]).Tables["Employee"].Copy();

                // Specify the column list and headers to export
                int[]    iColumns = { 1, 2, 3, 5, 6 };
                string[] sHeaders = { "LastName", "FirstName", "DOB", "Address", "ZipCode" };

                // Export the details of specified columns with specified headers to CSV
                RKLib.ExportData.Export objExport = new RKLib.ExportData.Export();
                objExport.ExportDetails(dtEmployee, iColumns, sHeaders, Export.ExportFormat.CSV, "EmployeesInfo3");
            }
            catch (Exception Ex)
            {
                lblError.Text = Ex.Message;
            }
        }
Esempio n. 9
0
        private void btnExportCSV_Click(object sender, System.EventArgs e)
        {
            lblMessage.Text = "";
            DataTable dt   = ds.Tables["Table1"].Copy();
            int       nCol = ds.Tables["Table1"].Columns.Count;

            int[] iColumns = new int[nCol];
            for (int i = 1; i < nCol; i++)
            {
                iColumns[i] = i;
            }
            try
            {
                string file = textBoxFolder.Text + "table1.csv";
                RKLib.ExportData.Export objExport = new RKLib.ExportData.Export("Win");
                objExport.ExportDetails(dt, iColumns, Export.ExportFormat.CSV, file);
                lblMessage.Text = "Successfully exported to " + file;
            }
            catch (Exception Ex)
            {
                lblMessage.Text = Ex.Message;
            }
        }
        private void btnExportExcel_Click(object sender, System.EventArgs e)
        {
            lblMessage.Text = "";
            // Export all the details
            try
            {
                // Get the datatable to export
                DataTable dtEmployee = dsEmployee.Tables["Employee"].Copy();

                // Export all the details to Excel
                RKLib.ExportData.Export objExport = new RKLib.ExportData.Export("Win");
                objExport.ExportDetails(dtEmployee, Export.ExportFormat.Excel, "C:\\EmployeesInfo.xls");
                lblMessage.Text = "Successfully exported to C:\\EmployeesInfo.xls";
            }
            catch(Exception Ex)
            {
                lblMessage.Text = Ex.Message;
            }
        }
        private void btnExportCSV_Click(object sender, System.EventArgs e)
        {
            // Export all the details
            try
            {
                lblMessage.Text = "";
                // Get the datatable to export
                DataTable dtEmployee = dsEmployee.Tables["Employee"].Copy();

                // Specify the column list to export
                int[] iColumns = {1,2,3,5,6};

                // Export the details of specified columns to CSV
                RKLib.ExportData.Export objExport = new RKLib.ExportData.Export("Win");
                objExport.ExportDetails(dtEmployee, iColumns, Export.ExportFormat.CSV, "C:\\EmployeesInfo.csv");
                lblMessage.Text = "Successfully exported to C:\\EmployeesInfo.csv";
            }
            catch(Exception Ex)
            {
                lblMessage.Text = Ex.Message;
            }
        }
Esempio n. 12
0
        public static string ExportCsv(DataTable table)
        {
            if (table == null)
            {
                return "";
            }

            if (table.TableName == "")
            {
                table.TableName = "ExportedData";
            }

            string fileName = table.TableName.Replace(" ", "") + ".csv";

            RKLib.ExportData.Export x = new RKLib.ExportData.Export("Win");

            x.ExportDetails(table, RKLib.ExportData.Export.ExportFormat.CSV, fileName);

            return Config.FolderAppBin + fileName;
        }
    private void DoExport(Boolean bToCSV)
    {
        ClassReport oRep = new ClassReport();
        DataSet oDs = GetGridData();
        Boolean bOkay = false;

        this.RowError1.Visible = false;
        this.RowError2.Visible = false;

        if (oDs != null)
        {
            if (oDs.Tables.Count > 0)
            {
                if (oDs.Tables[0].Rows.Count > 0)
                {
                    bOkay = true;
                }
            }
        }

        if (bOkay == true)
        {
            RKLib.ExportData.Export oExp = new RKLib.ExportData.Export("Web");

            Int32[] Columns = { 0, 1, 2 };

            if (bToCSV == true)
            {
                //	Export to CSV file.

                oExp.ExportDetails(oDs.Tables[0], Columns, RKLib.ExportData.Export.ExportFormat.CSV, "Report.csv");
            }
            else
            {
                //	Export to Microsoft Excel.

                oExp.ExportDetails(oDs.Tables[0], Columns, RKLib.ExportData.Export.ExportFormat.Excel, "Report.xls");
            }
        }
        else
        {
            this.RowError1.Visible = true;
            this.RowError2.Visible = true;
            this.LblMsg.Text = "No Data Found!";
        }
    }
Esempio n. 14
0
        private void btnExport3_Click(object sender, System.EventArgs e)
        {
            // Export the details of specified columns with specified headers

            try
            {
                // Get the datatable to export
                DataTable dtEmployee = ((DataSet) Session["dsEmployee"]).Tables["Employee"].Copy();

                // Specify the column list and headers to export
                int[] iColumns = {1,2,3,5,6};
                string[] sHeaders = {"LastName", "FirstName", "DOB", "Address", "ZipCode"};

                // Export the details of specified columns with specified headers to CSV
                RKLib.ExportData.Export objExport = new RKLib.ExportData.Export();
                objExport.ExportDetails(dtEmployee, iColumns, sHeaders, Export.ExportFormat.CSV, "EmployeesInfo3");
            }
            catch(Exception Ex)
            {
                lblError.Text = Ex.Message;
            }
        }