Html table with fixed header and scrollable

Html table with fixed header and scrollable
<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      .tableFixHead {
        overflow-y: auto;
        height: 100px;
      }
      .tableFixHead thead th {
        position: sticky;
        top: 0;
      }
      table {
        border-collapse: collapse;
        width: 100%;
      }
      th,
      td {
        padding: 8px 16px;
      }
      th {
        background: #eee;
      }
      .tableFixHead,
      .tableFixHead td {
        box-shadow: inset 1px -1px #000;
      }
      .tableFixHead th {
        box-shadow: inset 1px 1px #000, 0 1px #000;
      }
    </style>
  </head>
  <body>
    <div class="tableFixHead">
      <table>
        <thead>
          <tr>
            <th>Col 1</th>
            <th>Col 2</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>1.1</td>
            <td>2.1</td>
          </tr>
          <tr>
            <td>1.2</td>
            <td>2.2</td>
          </tr>
          <tr>
            <td>1.3</td>
            <td>2.3</td>
          </tr>
          <tr>
            <td>1.4</td>
            <td>2.4</td>
          </tr>
          <tr>
            <td>1.5</td>
            <td>2.5</td>
          </tr>
        </tbody>
      </table>
    </div>
  </body>
</html>
Col 1Col 2
1.12.1
1.22.2
1.32.3
1.42.4
1.52.5

Json file – dataset – xml – text file

If you want to map the columns of json and xml file and then convert it to .txt file, Below is the code

private static void APIJsonData()
{
string json = File.ReadAllText(@"C:\SourceCode\Files\JsonFiles\jsondata.json");
var dataset = ReadDataFromJson(json, XmlReadMode.InferTypedSchema);
string xmlFileName = @"C:\SourceCode\Files\XmlFiles\" + "jsontoxml" + DateTime.Now.ToString("yyyyMMdd_hhmmss") + ".xml";
DataSet ds = new DataSet();
dataset.WriteXml(xmlFileName);
XmlDocument doc1 = new XmlDocument();
doc1.Load(xmlFileName);
 using (StreamWriter sw = new StreamWriter(@"C:\SourceCode\Files\TextFiles\" + "xmltoTxt" + DateTime.Now.ToString("yyyyMMdd_hhmmss") + ".txt"))
        {
            PrintNode(doc1.ChildNodes[1], sw);
            sw.Close();
        }

        var stringjsonData = json;

    }

private static void PrintNode(XmlNode xNode, StreamWriter writer){
bool printComma=false;int Cnt = 0;
// Check if the current node has just one level of child nodes

if (xNode.ChildNodes[0].ChildNodes.Count == 1){
//print the child nodes
writer.Write("'");

           
foreach (XmlNode chNode in xNode.ChildNodes)
            {
                Cnt++;
                printComma = false;
                XmlNodeList innerNodeList = chNode.ChildNodes;

                if (innerNodeList.Count > 1)
                {
                    if (chNode.Name != chNode.PreviousSibling.Name)
                    {
                        printComma = true;
                        writer.Write(writer.NewLine);
                        foreach (XmlNode innerNode in innerNodeList)
                        {
                            writer.Write(chNode.Name + "."+ innerNode.Name + " | ");
                        }
                    }
                }
                else
                {
                    printComma = true;
                    writer.Write(xNode.Name +"."+ chNode.Name);
                }

                if (Cnt != xNode.ChildNodes.Count)
                {
                    if (printComma == true)
                    {
                        writer.Write(",");
                    }
                }
            }
                writer.Write(writer.NewLine);
        }
        else
        {
            foreach (XmlNode chNode in xNode.ChildNodes)
            {
                // recursively calling the method to get to the Node where the node will have only one level of child nodes.  
                PrintNode(chNode, writer);
            }
        }

        ////////////////////////////////////////////////////////

        int count = 0;  
        // Check if the current node has just one level of child nodes  
        if (xNode.ChildNodes[0].ChildNodes.Count == 1)  
        {  
            //print the child nodes  
            writer.Write("'");
            foreach (XmlNode chNode in xNode.ChildNodes)
            {
                count++;
                XmlNodeList innerNodeList = chNode.ChildNodes;

                if (innerNodeList.Count > 1)
                {
                    writer.Write(writer.NewLine);
                    foreach (XmlNode innerNode in innerNodeList)
                    {
                        writer.Write(innerNode.InnerText + " | ");
                    }
                }
                else
                {
                    writer.Write(chNode.InnerText);
                }

                if (count != xNode.ChildNodes.Count)
                {
                     writer.Write(",");
                }
            }
            writer.Write(writer.NewLine);  
        }
      else
         {
              foreach (XmlNode chNode in xNode.ChildNodes)
              {
                      // recursively calling the method to get to the Node where the node will have only one level of child nodes.  
                    PrintNode(chNode, writer);
              }
          }
  }  



       

Datatable to excel download in MVC

 [HttpPost]
        [ValidateInput(false)]
        public ActionResult Export()
        {
            DataTable dt = new DataTable(); 
            dt.Clear();
            dt.Columns.Add("Name");
            dt.Columns.Add("Marks");
            DataRow _ravi = dt.NewRow();
           _ravi["Name"] = "ravi";
           _ravi["Marks"] = "500";
            dt.Rows.Add(_ravi);
            //open file

            string filePath = @"D:\\Book1bb.xls";
            StreamWriter wr = new StreamWriter(filePath);
            
            try
            {
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    wr.Write(dt.Columns[i].ToString().ToUpper() + "\t");
                }
                wr.WriteLine();

                //write rows to excel file
                for (int i = 0; i < (dt.Rows.Count); i++)
                {
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        if (dt.Rows[i][j] != null)
                        {
                            wr.Write(Convert.ToString(dt.Rows[i][j]) + "\t");
                        }
                        else
                        {
                            wr.Write("\t");
                        }
                    }
                    //go to next line
                    wr.WriteLine();
                }
                //close file
                wr.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            string fileName = Path.GetFileName(filePath);

            byte[] fileBytes = GetFile(filePath);
            return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
        }

        byte[] GetFile(string s)
        {
            System.IO.FileStream fs = System.IO.File.OpenRead(s);
            byte[] data = new byte[fs.Length];
            int br = fs.Read(data, 0, data.Length);
            if (br != fs.Length)
                throw new System.IO.IOException(s);
            return data;
        }

.Net Professional, Searching for one job

Hi,

My email ID is mmkdotnet@gmail.com , My contact number is +91 9986248107

I’m in the software .Net field  Now I’m in search of job. I need one job urgently.

I can develop a website, I can manage your existing website, I can enhance your existing projecct.

Also I’m keen to switch into different roles like HR Positions, Assistant Positions, Looking for business opportunity as well

I’m Experienced Senior .Net Technical Lead and Full Stack Developer and Microsoft Certified Professional. Experience 10 yrs. in Net web based applications, 3 yrs. in windows based: – Overall 13 yrs.

As a Individual contributor developed 5 web applications, 2 Mobile Applications,and as a team member developed 10+ project.

My Skills –  C#, ASP.Net Web Forms,Asp.Net MVC,HTML,Web API,Web Services,SQL Server, Cordova, CSS, JavaScript, JQuery, Bootstrap

Knowledge in Asp.Net Core, Blazor, Angular 8, Azure, Mobile App Development

Thanking you

 

 

 

 

 

Post Bulk Data $ajax type post

function PostBulkData() {
try {

var result = confirm(“Do you want to update!”);
if (result == true) {
var empty = ”;
var SomeArrayData = []
var sts = ”;

for (var ix = 0; ix <= LoadedJsonData.length – 1; ix++) {
var deliveryNoteDetails = {
ID: 0,
Delivery_Note_ID: LoadedJsonData[ix].ID,
Delivery_ID: LoadedJsonData[ix].Delivery_ID,
Del_Date: LoadedJsonData[ix].Del_Date,
Cust_Account_ID: LoadedJsonData[ix].Cust_Account_ID,
Cust_Account_Number: LoadedJsonData[ix].Cust_Account_Number,
Cust_Name: LoadedJsonData[ix].Cust_Name,
Some_ID: LoadedJsonData[ix].Some_ID,
Item_Code: LoadedJsonData[ix].Item_Code,
Item_Decription: LoadedJsonData[ix].Item_Decription,
UOM: LoadedJsonData[ix].UOM,
Del_Qty: LoadedJsonData[ix].Del_Qty,
Status: sts,
AddedOn: empty,
AddedBy: window.sessionStorage.getItem(‘username’),
ModifiedOn: empty,
ModifiedBy: empty
}
SomeArrayData.push(deliveryNoteDetails);
}

var jsonParamsArrayData = []
var jsonParams = {
Some_ID: window.localStorage.getItem(‘someID’),
}
jsonParamsArrayData.push(jsonParams);

// var jsonData = JSON.stringify(DeliveryNoteDetailsTransaction);
// var jsonParameters = JSON.stringify(jsonParamsArray);
var scannedArrayData = [];
var scannedData = {
SlNo: ‘NoData’
}
scannedArrayData.push(scannedData);

var signatureArrayData = [];
var signData = {
Sign: ‘NoData’
}
signatureArrayData.push(signData);

var EmptyscannedArrayData = [];
var scannedData = {
SlNo: ‘NoData’
}
EmptyscannedArrayData.push(scannedData);

var postData = {};
postData.SomeArrayData = SomeArrayData;
postData.jsonParamsArrayData = jsonParamsArrayData;
postData.scannedArrayData = scannedArrayData;
postData.signatureArrayData = signatureArrayData;
postData.EmptyscannedArrayData = EmptyscannedArrayData;

$.ajax({
type: ‘POST’,
async: true,
headers: {
‘Content-Type’: ‘application/x-www-form-urlencoded; charset=UTF-8’
},
dataType: “json”,
url: window.sessionStorage.getItem(“webAPI”) + ‘ControllerNm/GetPostMethdName?type=json’,
data: postData,
beforeSend: function(xhr) {
if (isEmpty(window.localStorage.getItem(‘token’))) {
//xhr.setRequestHeader(‘Authorization’, “Bearer ” + window.localStorage.getItem(‘token’));
//xhr.setRequestHeader(“X-Requested-With”, “XMLHttpRequest”);
}
$(“#loading-img”).css({
“display”: “block”
});
},
success: function(data) {
if (data == ‘Success’) {
//updateStatus();
alert(‘Status Updated’);
window.location = “Master.html”
return true;
} else {
alert(‘Failed while inserting transaction details’);
$(“#loading-img”).css({
“display”: “none”
});
return;
}

},
error: function(xhr, status, error) {
$(“#loading-img”).css({
“display”: “none”
});
alert(xhr.responseText);
}
});

} else {
return;
}

} catch (err) {
alert(err.message);
}
}