[ 01011011 @ 11.01.2007. 16:04 ] @
Radim na web aplikaciji i sta se dogadja imam upload excel file opciju na sajtu. E sad taj excel fajl moze imati 30 redova (rows) ali kad ga sacuvaju neki korisnici, samo se formatira i sacuva svih 65000 redova, tako kad se to uploaduje, dost ami e se praznih redova uploduje sto dovodi to tajmauta i svega. U pitanju je C# i web aplikacija, kako da se pregledaju broj redova koji postoji i ignorisu prazni redovi.

Hvala
[ Vranac @ 11.01.2007. 17:54 ] @
Obzirom da rece preko IM-a da je u pitanju CSV koji se onda parsira, i treba da se izbegnu prazni redovi,
moglo bi ovako, malo sirovo ali radi.

Code:

using System.IO;
....

try
        {

            string myFile = Server.MapPath("~\\file.csv"); //enter path to yor file

            using (StreamReader sr = new StreamReader(myFile))
            {
                String line;
                // Read and display lines from the file until the end of 
                // the file is reached.
                while ((line = sr.ReadLine()) != null)
                {
                    string[] myLine = line.Split(new char[] { ',', ' ' }); //add separators
                    bool fHasValue = false;
                    for (int i = 0; i < myLine.Length; i++)
                    {
                        if (myLine[i].Length > 0)
                        {
                            fHasValue = true;
                        }
                    }

                    if (fHasValue == false)
                    {
                        Trace.Warn("empty line is " + line);
                        // empty row
                    }
                    else
                    {
                        Trace.Warn(" line is " + line);
                        //do something :)
                    }
                }
            }
        }
        catch (Exception ex)
        {
            // Let the user know what went wrong.
            Trace.Warn("The file could not be read:");
            Trace.Warn(ex.Message);
        }



[ 01011011 @ 11.01.2007. 18:47 ] @
brate trebaces mi jos :) javi se na icq :)