Ir para conteúdo
Fórum Script Brasil
  • 0

Componente Excelapplication Para Inserir Formulas


Guest Franciel

Pergunta

Guest Franciel

Ae gente .. to com um probleminha na exportacao para uma planilha do excel.

Quando tento inserir uma formula num celula em vez de aparecer o resultado aparece #NOME? e to usando o seguinte codigo:

Texto := '=SOMA(E3:E'+strLinha+')';

Range['E'+IntToStr(Linha),'E'+IntToStr(Linha)].Value := Texto;

Texto := '=SOMA(G3:G'+strLinha+')';

Range['G'+IntToStr(Linha),'G'+IntToStr(Linha)].Value := Texto;

alguém pode me ajudar???

alguém sabe de um tutorial q ensina a usar esse componente?

Link para o comentário
Compartilhar em outros sites

5 respostass a esta questão

Posts Recomendados

  • 0

Ae programador, to usando esse codigo:

LCid := GetUserDefaultLCID;

Try

xlApp.Connect;

xlApp.Visible[LCid] := true;

xlApp.Caption := Title;

// adicionando uma planilha

xlApp.Workbooks.Add(EmptyParam, LCid);

Arquivo := xlApp.Workbooks.Item[1];

// Recebe a planilha criada

Planilha := Arquivo.Worksheets.Get_Item(1) as _WorkSheet;

Planilha.Name := Title;

Planilha.Columns.Font.Size := 10;

Planilha.Columns.Font.Name := 'Arial';

Planilha.Columns.HorizontalAlignment := xlCenter;

with xlApp do

begin

// Criando as colunas

xlApp.Range['A1','G1'].Value := VarArrayOf(['CODIGO',

'REF. FABR.','DESCRICAO','UNIDADE','ESTOQUE','CUSTO','TOTAL']);

// Formatando a Planilha Linha

with Range['A1','G1']do

begin

HorizontalAlignment := xlcenter;

VerticalAlignment := xlBottom;

Wraptext := false;

Orientation := 0;

ShrinkTofit := false;

MergeCells := false;

Font.Bold := true;

Font.Size := 10;

end;

while not Eof do

Begin

if (rdgTipo.ItemIndex = 0) then

begin

Range['A'+IntToStr(Linha),'G'+IntToStr(Linha)].Value := VarArrayOf([FieldByName('CodPro').AsString,

FieldByName('CodProFabr').AsString,FieldByName('DescDescPro').AsString,

FieldByName('CodUn').AsString, MascaraVlr ('######0.00', FieldByName ('Estoque').AsFloat),

MascaraVlr ('######0.00', FieldByName ('Precus').AsFloat),

MascaraVlr ('######0.00', FieldByName ('Estoque').AsFloat * FieldByName ('Precus').AsFloat)]);

Total := Total + (FieldByName ('Estoque').AsFloat * FieldByName ('Precus').AsFloat);

end

else

begin

Range['A'+IntToStr(Linha), 'G'+IntToStr(Linha)].Value := VarArrayOf([FieldByName('CodPro').AsString,

FieldByName('CodProFabr').AsString,FieldByName('DescDescPro').AsString,

FieldByName('CodUn').AsString, FieldByName ('Estoque').AsString,

FieldByName('PreVenda').AsString,

FloatToStr(FieldByName ('Estoque').AsFloat * FieldByName ('PreVenda').AsFloat)]);

Total := Total + (FieldByName ('Estoque').AsFloat * FieldByName ('PreVenda').AsFloat);

end;

TotalEst := TotalEst + FieldByName ('Estoque').AsFloat;

Inc(Linha);

Next;

end;

strLinha := IntToStr(Linha-1);

Range['E3','G'+strLinha].NumberFormat := '#####0.00';

Linha := Linha + 2;

Planilha.Cells.Item[Linha, 3] := 'TOTAL GERAL';

Range['A1','G'+IntToStr(Linha)].Columns.AutoFit;

// Essas Linha são referente a fomula q deveria ser inserida no excel

Texto := '=SOMA(E3:E'+strLinha+')';

Range['E'+IntToStr(Linha),'E'+IntToStr(Linha)].Formula := Texto;

Texto := '=SOMA(G3:G'+strLinha+')';

Range['G'+IntToStr(Linha),'G'+IntToStr(Linha)].Value := Texto;

Range['A2','G'+IntToStr(Linha)].AutoFormat(xlRangeAutoFormatClassic1,true,

true,true,true,true,true);

Vlws!!!!

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.


  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...