c# Datatable (2) console, Excel reading and output

1. Console output Code #region output DataTable public static void print_DT(DataTable dt) {<!– –> if (dt.Rows.Count > 0) {<!– –> //Print all column names string columnName = string.Empty; //Print short lines string line_str=””,line = “-“; int long_number = 40;//Fixed length of each column //Print column names and dashes for (int i = 0; i < […]

C#Json string to DataTable, DataSet JsonConvert.DeserializeObject loss of precision problem

C# Json string to DataTable, DataSet JsonConvert.DeserializeObject loss of precision problem Problem description When I was converting Json string to DataTable, I found that if I have a column of decimals, but the first row is an integer, all decimal digits below will be lost. Example public const string _InvoiceDataJsonTable = “[{“EXCHANGE_USD”:24},{“EXCHANGE_USD”:15},{“EXCHANGE_USD”: 191.06}]”; DataTable dtTable […]

DataTable data is exported and saved to a file, and Excel files are imported into DataTable.

1. Convert DataTable into Excel table, export and save to file // GET: /Excel/ Models.zbwxglEntities myMdl = new Models.zbwxglEntities(); /// <summary> /// The first method is to use the file output stream to perform read and write operations. /// </summary> public void outExcel(DataTable table) { DataTable dtData = table; string shtnl = “”; shtnl = […]

Parsing request parameters using jQuery dataTables – 3

I have been very busy recently and have not updated. I will post an article on dataTables parameter processing first. For dataTables, when using server-side paging, multiple parameters will be passed to the server, and server-side paging processing will be performed on the server side based on these parameters. There are many parameters. For detailed […]

C# on the implementation of converting Excel files to DataTable and TXT text

C# about the implementation of converting Excel files to DataTable and TXT text FileToDataTable /// <summary> /// /// </summary> /// <param name=”fileName”>File path Path + FileName</param> /// <param name=”sheetName”>Page signature</param> /// <returns></returns> private DataTable FileToDataTable(string fileName, string sheetName) { DataSet dst = new DataSet(); DataTable dt = new DataTable(); dt = XlsToDataTable(fileName, sheetName); return dt; […]

Json to DataTable

Json to DataTable Simple /// <summary> /// Convert json to DataTable /// </summary> /// <param name=”strJson”>The obtained json</param> /// <returns></returns> public static DataTable JsonToDT(string strJson) { //Convert json format strJson = strJson.Replace(“,””, “*””).Replace(“”:”, “”#”).ToString(); //Get the table name var rg = new Regex(@”(?<={)[^:] + (?=:\[)”, RegexOptions.IgnoreCase); string strName = rg.Match(strJson).Value; DataTable tb = null; //remove […]

Python Flask parses ajax request parameters sent by jQuery DataTables

Background The front end uses the jQuery DataTables control to initiate an ajax request to the back end, and the back end uses the Flask framework to parse the problem encountered in request parameters. The request parameters are as shown below: Backend gets parameters from flask import Flask, request print request.query_string ‘draw=1 & amp;columns[0][data]=name & […]

DataTables.js comprehensive application development (ajax filter query, same column data summary, chain data)

Filter data <!–Filter data–> <div class=”layui-card” style=”margin-bottom: 50px;”> <div class=”layui-row”> <form class=”layui-form layui-col-md12″ style=”margin: 10px;”> <div class=”demoTable” style=”width: 100%;”> <div class=”layui-input-inline”> <select name=”sensorStatusVal” id=”sensorStatusVal” class=”layui-input”> <option value=””>Running status</option> <option value=”Normal”>Normal</option> <option value=”Alarm”>Alarm</option> <option value=”Offline”>Offline</option> </select></div> <div class=”layui-input-inline”> <input type=”text” class=”layui-input” placeholder=”region” id=”sub_region” autocomplete=”off”> </div> <div class=”layui-input-inline”> <input type=”text” class=”layui-input” placeholder=”class name” id=”device” autocomplete=”off”> </div> <a […]

C# neatly outputs DataTable in the console

Effect: 1. Foreword On the Winform platform, controls such as DataGridView can be used to display the form data of the database, but in the C# console project, if the database query is useful, it is more difficult for us to see the effect of the query statement. For example, I write at will A […]

[C#] Mutual conversion between entity class and DataTable, entity reflection dynamic traversal column

In actual projects, mutual conversion between data is often used, and serialization and deserialization are common scenarios. Here we only briefly talk about the conversion between entity classes and DataTables, which can be used in different business scenarios. Table of Contents 1. DataTable to Model 2. Model to DataTable 3. The concept of reflection 3.1, […]