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;
        }

Add Placeholder text in Excel from VB.Net

If you want to display placeholder text in excel cell, so that user can know what should be entered and on entering the placeholder text goes and entered value will be shown, then you need to format cell as custom format and give below formula

General;General;[Color15]”dd-MMM-yyyy”

Below is the VB.Net code , if you want to do through coding

Protected Sub btn_Click(sender As Object, e As EventArgs)
Using wb = New XLWorkbook()
Dim ws = wb.AddWorksheet(“Sheet1”)
Dim cell = ws.FirstCell()
cell.Value = 0.0
‘cell.DataType = XLDataType.DateTime
cell.Style.NumberFormat.Format = BuildWatermarkFormat(“dd-MMM-yyyy”) ‘”_ * # ##0.00_ ;_ * -# ##0.00_ ;_ * “”-“”??_ ;_ @_ “
‘cell.Style.NumberFormat.SetNumberFormatId(43)
‘cell.Value = 0
ws.Columns(“A”).AdjustToContents()
wb.SaveAs(“d:\test.xlsx”)
End Using
End Sub

Public Function BuildWatermarkFormat(ByVal watermarkText As String, Optional ByVal positiveFormat As String = “General”, Optional ByVal negativeFormat As String = “General”, Optional ByVal textFormat As String = “General”) As String
BuildWatermarkFormat = positiveFormat & “;” & negativeFormat & “;[Color15]” & Chr(34) & watermarkText & Chr(34) & “;” & textFormat
End Function

Interview Topics

Topics to be read before attending interview

OOPS (AEIP)
23 DESIGN PATTERNS –

https://medium.com/@buihuycuong/the-23-gang-of-four-design-patterns-974ae8d1a957

http://geekswithblogs.net/subodhnpushpak/archive/2009/09/18/the-23-gang-of-four-design-patterns-.-revisited.aspx

  1. SOLID PRINCIPLES – https://medium.com/mindorks/solid-principles-explained-with-examples-79d1ce114ace
  2. MVC FILTERS – https://www.tutorialsteacher.com/mvc/filters-in-asp.net-mvc
  3. ASP.NET CORE
  4. WEB API Exceptions – https://www.exceptionnotfound.net/the-asp-net-web-api-exception-handling-pipeline-a-guided-tour/
  5. Extension methods – https://www.tutorialsteacher.com/csharp/csharp-extension-method
  6. Delegates –
  7. Async
  8. Threading
  9. Design Patterns

  10. ANGULAR
    PWA
    AZURE
    SQL SERVER

AWS

COMPLETE WEBSITE UI DESIGN SAMPLES LIKE ONLINE STORE
ADOBE XD
ANGULAR CRUD WITH CORE
VUE CRUD WITH API

CRUD Example videos to be seen

Asp.Net Core – CRUD

Web API – CRUD

Asp.Net MVC – CRUD

Angular – CRUD