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



       

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

How to Identify .dll file is 32 bit or 64 bit?

A DLL or Dynamic Link Library file is a kind of file that contains specific code that one or more programs can share. The .dll file will support to execute the program.

If you want your application to run on both 32-bit and 64-bit operating systems, you need to build your project as 32-bit (x86 CPU) and include the 32-bit DLLs.

32 bit computer uses 32 bit for its memory addresses and 64 bit computer uses 64 bit for its memory addresses.A bit (short for binary digit) is the smallest unit of data in a computer. A bit has a single binary value, either 0 or 1.

If you come to situation to identify the .dll is of how many bit,then you can use Continue reading