Cell does not show all information(.CSV)

Asked

Viewed 39 times

0

I am generating a file . CSV in my project in c#. Most information is correct, but when it has a large number, the cell does not show all:

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

and the file is generated like this:

Call the Create Function

var arquivo = Service.CriarArquivo(paraEnviar, inclusaoRadioButton.Checked, motivo);

Function of creating

public Arquivo CriarArquivo(IDictionary<Cliente, IEnumerable<ContasReceber>> clientes)
{
     Arquivo arquivo = new Arquivo();
     var config = GetConfiguracao();
     PreencherCabecalho(arquivo, config);
     PreencherDetalhe(arquivo, config, clientes);
     return arquivo;
}

Fill in Detail

arquivo.Detalhe = new List<Detalhe>();
int sequencial = 1;
foreach (var c in clientes)
{
   Detalhe d = new Detalhe();
   var cob = c.Value.First();
   d.DocumentoDoPrincipal = c.Key.Cnpj;
   if (!String.IsNullOrEmpty(c.Key.Telefone) && c.Key.Telefone.Length == 10)
   {
      d.DDD = int.Parse(c.Key.Telefone.Substring(0, 2));
      d.Tel = long.Parse(c.Key.Telefone.Substring(2, 8));
   }
   d.DtVencDivida = cob.DataVencimento.Value;
   arquivo.Detalhe.Add(d);
}

Detail:

[Line(Length = 600)]
public class Detalhe
{
   [Column(Length = 20)]
   public string DocumentoDoPrincipal { get; set; }
   [Column(Format = "000")]
   public int DDDDevedor { get; set; }
   [Column(Format = "00000000")]
   public long TelDevedor { get; set; }
   [Column(Format = "dd/MM/yyyy")]
   public DateTime DtVencDivida { get; set; }
}

The goal is just to have all the characters appear, the size of the cell doesn’t matter.

  • 1

    The problem is in the configuration of Excel columns, but I think with CSV file can not change it programmatically. If you used Excel Interops, then it would be different.

  • @Joãomartins then without modifying in the spreadsheet itself, there is no way?

  • @Brunomiqueas opens your CSV in a text editor to check that the data is correct. The problem there is that Excel can not show all the information of your column because it is too narrow. Try increasing the column size. It is problem in the presentation of excel data even, it is not in the data.

  • 2

    To modify this you would have to use another format like the .xlsx that have metadata and can save information as the width of column X. A CSV file is just a TXT file with a specific pattern.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.