I have a situation where I have to convert excel single column to utf-8 and then to base64.
 I have gone through several post which suggests how to read excel file.
Reading Excel files from C# 
But I am not sure that in my situation which is the best approach.
I have big files of 2MB. 
Kindly suggest me.
            Asked
            
        
        
            Active
            
        
            Viewed 1,742 times
        
    -1
            
            
        1 Answers
0
            I got the solution
using System;
using System.Drawing;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel; 
namespace WindowsApplication1
{
 public partial class Form1 : Form
 {
    public Form1()
    {
        InitializeComponent();
    }
    private void button1_Click(object sender, EventArgs e)
    {
         bgw.RunWorkerAsync();
        var myConnection = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='c:\\Language_Batch1_OneClick.xls';Extended Properties=Excel 8.0;"); ;
        var myCommand = new OleDbCommand();
        var upCommand = new OleDbCommand();
        int i = 0;
        try
        {
            string sql = null;
            myConnection.Open();
            myCommand.Connection = myConnection;
            sql = "select ANSWER_CODE,Punjabi from [Batch_Lang_1$]";
            myCommand.CommandText = sql;
            var dataReader = myCommand.ExecuteReader();
            while (dataReader.Read())
            {
                var langText = Convert.ToBase64String(Encoding.UTF8.GetBytes(dataReader["Punjabi"].ToString()));
                if (langText.Length >= 1000)
                {
                    continue;
                }
                var ansCode = dataReader["ANSWER_CODE"].ToString();
                sql = "update [Batch_Lang_1$] set Punjabi= '" + langText + "'  where ANSWER_CODE='" + ansCode + "'";
                upCommand.Connection = myConnection;
                upCommand.CommandText = sql;
                upCommand.ExecuteNonQuery();
                i++;
            }
    }
 }
}
 
    
    
        शेखर
        
- 17,412
- 13
- 61
- 117
- 
                    But what does this got to do with utf8 and base64? – Dane Balia Nov 19 '12 at 09:39
- 
                    I am still working on this but I got an idea. I have update my answer have a look. – शेखर Nov 19 '12 at 09:43
