public static void FL_data_to_xls(string dbfFilepathWithNameAndExtension) { string constring = FL_Dbf_Manager.FL_dbf_constring(dbfFilepathWithNameAndExtension); string sWithoutExt = Path.GetFileNameWithoutExtension(dbfFilepathWithNameAndExtension); string query = "SELECT * FROM " + sWithoutExt; DataTable dt = FL_Oledb_Helper.FL_Oledb_Manager.FL_get_oledb_datatable(constring, query); FL_DataTableToExcel_Helper.FL_DataTableToExcel(dt, Path.GetDirectoryName(dbfFilepathWithNameAndExtension) + @"\" + Path.GetFileNameWithoutExtension(dbfFilepathWithNameAndExtension)); }
/// <summary> /// The FL_data_to_xls /// </summary> /// <param name="DbfFilepathWithNameAndExtension">The DbfFilepathWithNameAndExtension<see cref="string"/></param> public static void FL_data_to_xls(this string DbfFilepathWithNameAndExtension) { var Constring = DbfFilepathWithNameAndExtension.FL_dbf_constring(); var sWithoutExt = Path.GetFileNameWithoutExtension(DbfFilepathWithNameAndExtension); var Query = "SELECT * FROM " + sWithoutExt; var dt = _OledbHelper.FL_get_oledb_datatable(Constring, Query); FL_DataTableToExcel_Helper.FL_DataTableToExcel(dt, Path.GetDirectoryName(DbfFilepathWithNameAndExtension) + @"\" + Path.GetFileNameWithoutExtension(DbfFilepathWithNameAndExtension)); }
/// <summary> /// The FL_data_to_xls /// </summary> /// <param name="Query">The Query<see cref="string"/></param> /// <param name="Constring1">The Constring1<see cref="string"/></param> /// <param name="DbfFilepathWithNameAndExtension">The DbfFilepathWithNameAndExtension<see cref="string"/></param> public static void FL_data_to_xls(string Query, string Constring1 = null, string DbfFilepathWithNameAndExtension = null) { if (string.IsNullOrEmpty(DbfFilepathWithNameAndExtension)) { var dt = _OledbHelper.FL_get_oledb_datatable(Constring1, Query); var filename = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\" + dt.TableName; FL_DataTableToExcel_Helper.FL_DataTableToExcel(dt, filename); } else { var Constring = DbfFilepathWithNameAndExtension.FL_dbf_constring(); //var sWithoutExt = Path.GetFileNameWithoutExtension(DbfFilepathWithNameAndExtension); var dt = _OledbHelper.FL_get_oledb_datatable(Constring, Query); FL_DataTableToExcel_Helper.FL_DataTableToExcel(dt, Path.GetDirectoryName(DbfFilepathWithNameAndExtension) + @"\" + Path.GetFileNameWithoutExtension(DbfFilepathWithNameAndExtension)); } }
private void button2_Click(object sender, EventArgs e) { //MessageBox.Show(DateTime.Now.ToString()); //MessageBox.Show("OS Version: "+frontlook_csharp_library.FL_General.FL_Os_Helper.FL_get_os()); dataGridView1.DataSource = ""; if (dbf_filepath.Equals("") || dbf_filepath.Equals(string.Empty)) { dbf_folder_selection(); var v = FL_Dbf_Manager.FL_dbf_datatable(dbf_filepath, query.Text.ToString().Trim()); v.TableName = "Table1"; FL_DataTableToExcel_Helper.FL_DataTableToExcel(v, Path.GetDirectoryName(dbf_filename)); //dataGridView1.DataSource = v; /* * SELECT smast.SDES as SDES,bill.DT,billmed.VNO,billmed.BATCH,billmed.EXPDT, bill.MPT,aconf.ADD1,aconf.ADD2,aconf.ADD3, (SELECT smast.SDES FROM [smast],[bill] WHERE bill.LCOD=smast.SCOD AND bill.VNO='00534' AND bill.MPT='M') AS TRANSPORT_SDES FROM [billmed],[bill],[smast],[aconf] WHERE billmed.VNO = bill.VNO AND bill.SCOD=smast.SCOD AND bill.MPT='M' AND bill.SCOD=aconf.GCOD AND bill.VNO='00534' */ DataSet ds = new DataSet("client_info"); ds.Tables.Add(v); //ReportViewer rv = new ReportViewer(); rv.ShowPrintButton = true; rv.ShowProgress = true; //query.Text = query1; MessageBox.Show(ds.DataSetName); dataGridView1.DataSource = ds.Tables["table1"]; fast_report(); //db_viewer.RunWorkerAsync(); /*using (var report = new Report()) * { * report.Load("report1.frx"); * report.RegisterData(ds, "client_info"); * report.Prepare(true); * PDFSimpleExport export = new PDFSimpleExport(); * * report.Export(export, "result.pdf"); * //report.SavePrepared("a.pdf"); * //report.Save("a.pdf"); * * }*/ } else { /* * SELECT smast.SDES as SDES,bill.DT,billmed.VNO,billmed.BATCH,billmed.EXPDT, bill.MPT,aconf.ADD1,aconf.ADD2,aconf.ADD3, (SELECT smast.SDES FROM [smast],[bill] WHERE bill.LCOD=smast.SCOD AND bill.VNO='00534' AND bill.MPT='M') AS TRANSPORT_SDES FROM [billmed],[bill],[smast],[aconf] WHERE billmed.VNO = bill.VNO AND bill.SCOD=smast.SCOD AND bill.MPT='M' AND bill.SCOD=aconf.GCOD AND bill.VNO='00534' */ var v = FL_Dbf_Manager.FL_dbf_datatable(dbf_filepath, query.Text.ToString().Trim()); v.TableName = "Table1"; FL_DataTableToExcel_Helper.FL_DataTableToExcel(v, Path.GetDirectoryName(dbf_filename)); dataGridView1.DataSource = v; DataSet ds = new DataSet("client_info"); ds.Tables.Add(v); //ReportViewer rv = new ReportViewer(); rv.ShowPrintButton = true; rv.ShowProgress = true; //query.Text = query1; File.WriteAllText("C:\\Users\\deban\\Desktop\\xml.txt", v.DataSet.GetXml()); File.WriteAllText("C:\\Users\\deban\\Desktop\\xml1.txt", v.DataSet.GetXmlSchema()); MessageBox.Show(ds.DataSetName); /*using (var report = new Report()) * { * report.Load("C:\\Users\\deban\\Desktop\\dbtest.frx"); * report.RegisterData(ds, "client_info"); * report.Prepare(true); * PDFSimpleExport export = new PDFSimpleExport(); * * report.Export(export, "C:\\Users\\deban\\Desktop\\result.pdf"); * //report.SavePrepared("a.pdf"); * //report.Save("a.pdf"); * }*/ } /*using (var report = new Report()) * { * report.Load("report1.frx"); * report.RegisterData(t, "NorthWind"); * report.Prepare(true); * PDFSimpleExport export = new PDFSimpleExport(); * * report.Export(export, "result.pdf"); * //report.SavePrepared("a.pdf"); * //report.Save("a.pdf"); * }*/ /* var ci = new CultureInfo("en-IN"); * var cu = CultureInfo.CurrentUICulture.DateTimeFormat.FullDateTimePattern; * var cd = CultureInfo.CurrentCulture.DateTimeFormat.GetAllDateTimePatterns(); * MessageBox.Show(Thread.CurrentThread.CurrentCulture.ToString()); * MessageBox.Show(CultureInfo.CurrentCulture.Name + "1"); * CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; * var cf_d = currentCulture.DateTimeFormat.ShortDatePattern; * var cf_t = currentCulture.DateTimeFormat.LongTimePattern; * MessageBox.Show(cf_d + " 1 "+cf_t+" 2 "+ currentCulture.DateTimeFormat.FullDateTimePattern+" 3 "+ * currentCulture.DateTimeFormat.SortableDateTimePattern+" 4 "+ currentCulture.DateTimeFormat.LongDatePattern);*/ //MessageBox.Show(DateTime.ParseExact(DateTime.Now.ToString(),cf_d+" "+cf_t,ci,DateTimeStyles.AssumeLocal).ToString()); }