Jump to content


Photo

Php + Excel


  • Faça o login para participar
6 replies to this topic

#1 KAKO-

KAKO-

    loading: again.........

  • Usuários
  • 236 posts
  • Sexo:Não informado
  • Localidade:Joinville
  • Interesses:ASP / PHP

Posted 03/10/2006, 11:43

Seguinte galeria

jah tentei de tudo
classe, funcoes, COM (do windows), ODBC
ate chamei o diabo de meu loro mas nao deu certo...

O q eu preciso é o seguinte:

1 - Tenho um arquivo .xls (montado com suas funções), ou seja, ele já esta totalmente pronto e funcional;
2 - Eu gostaria de poder substituir / adicionar (CELULAS), sem ter que criar todo .xls novamente.

Portanto, minha questão é a seguinte: PRECISO DE UM SCRIPT / CLASSE / FUNÇÃO QUE TENHA A POSSIBILIDADE DE PODER ALTERAR ESSE .XLS

OBS: nao estou gritando, eh soh pra deixar com o foco para isso :D
<?php
$nome = "Flávio Rodrigues";
$site = "http://www.expresso.com.br";
$idade = "21";
?>

nada é uma palavra esperando tradução...

#2 kleryson

kleryson

    Mestre

  • Usuários
  • 687 posts
  • Sexo:Masculino

Posted 03/10/2006, 11:55

Mas afinal tem que ser em PHP??

Por quê não trabalha com VBA??

#3 KAKO-

KAKO-

    loading: again.........

  • Usuários
  • 236 posts
  • Sexo:Não informado
  • Localidade:Joinville
  • Interesses:ASP / PHP

Posted 03/10/2006, 11:57

sim sim, PHP
esqueci de informar esse pequeno detalhe
:D
<?php
$nome = "Flávio Rodrigues";
$site = "http://www.expresso.com.br";
$idade = "21";
?>

nada é uma palavra esperando tradução...

#4 kleryson

kleryson

    Mestre

  • Usuários
  • 687 posts
  • Sexo:Masculino

Posted 03/10/2006, 12:51

Cara encontrei um script mas não consegui destar pois o meu server é linux e pelo que vi só vai funcionar se for windows...

<?php
set_time_limit(0);
error_reporting(E_ALL);

#Set the workbook to use and its sheet. In this example we use a spreadsheet that
#comes with the Excel installation called: SOLVSAMP.XLS

$workbook = "C:\Program Files\Microsoft office\Office10\Samples\SOLVSAMP.XLS";
$sheet = "Quick Tour";

#Instantiate the spreadsheet component.
	$ex = new COM("Excel.sheet") or Die ("Did not connect");

#Get the application name and version	
	print "Application name:{$ex->Application->value}<BR>";
	print "Loaded version: {$ex->Application->version}<BR>";

#Open the workbook that we want to use.
	$wkb = $ex->application->Workbooks->Open($workbook) or Die ("Did not open");

#Create a copy of the workbook, so the original workbook will be preserved.
	$ex->Application->ActiveWorkbook->SaveAs("Ourtest");  
	#$ex->Application->Visible = 1; #Uncomment to make Excel visible.

# Read and write to a cell in the new sheet
# We want to read the cell E11 (Advertising in the 4th. Quarter)
	$sheets = $wkb->Worksheets($sheet);	#Select the sheet
	$sheets->activate;				 #Activate it
	$cell = $sheets->Cells(11,5);	#Select the cell (Row Column number)
	$cell->activate;				#Activate the cell
	print "Old Value = {$cell->value} <BR>";	#Print the value of the cell:10000
	$cell->value = 15000;			#Change it to 15000
	print "New value = {$cell->value}<BR> ";#Print the new value=15000

#Eventually, recalculate the sheet with the new value.
	$sheets->Calculate;			#Necessary only if calc. option is manual
#And see the effect on total cost(Cell E13)
	$cell = $sheets->Cells(13,5);	#Select the cell (Row Column number)
	$number = Number_format($cell->value);
	print "New Total cost =\$$number - was \$47,732 before.<BR>";
#Should print $57,809 because the advertising affects the Corporate overhead in the
# cell formula.

#Example of use of the built-in functions in Excel:
#Function: PMT(percent/12 months,Number of payments,Loan amount)
	$pay = $ex->application->pmt(0.08/12,10,10000);
	$pay = sprintf("%.2f",$pay);
		print "Monthly payment for $10,000 loan @8% interest /10 months: \$ $pay<BR>";
#Should print monthly payment = $ -1,037.03	
   
#Optionally, save the modified workbook
	$ex->Application->ActiveWorkbook->SaveAs("Ourtest");					  
#Close all workbooks without questioning
	$ex->application->ActiveWorkbook->Close("False");	
	unset ($ex);

?>

Não sei como funciona vou ter que montar um serve Windows para testar mais se alguém quiser o código está acima

Encontrei outros mais é pago

Edição feita por: kleryson, 03/10/2006, 12:53.


#5 KAKO-

KAKO-

    loading: again.........

  • Usuários
  • 236 posts
  • Sexo:Não informado
  • Localidade:Joinville
  • Interesses:ASP / PHP

Posted 03/10/2006, 13:34

kleryson,

esse script eu jah testei, funcionou corretamente
mas o q eu realmente preciso nao é a criação de .xls

preciso da alteração de .xls
<?php
$nome = "Flávio Rodrigues";
$site = "http://www.expresso.com.br";
$idade = "21";
?>

nada é uma palavra esperando tradução...

#6 kleryson

kleryson

    Mestre

  • Usuários
  • 687 posts
  • Sexo:Masculino

Posted 03/10/2006, 14:03

Achei agora uma class
Estava testando se quiser testar também:

Ok..


Vou passar o arquivo zip:

Attached Files


Edição feita por: kleryson, 03/10/2006, 14:09.


#7 KAKO-

KAKO-

    loading: again.........

  • Usuários
  • 236 posts
  • Sexo:Não informado
  • Localidade:Joinville
  • Interesses:ASP / PHP

Posted 03/10/2006, 14:17

ok, vou testar tb

obrigado pela ajuda ate entao

:D

kleryson,

Como eu havia dito, a criação do .xls eh tranquila, ate tenho outras classes q tambem funcionam (essa q vc me passou, tb funcionoui). mas o eu deseja não é a criação do .xls, eu preciso de da modificação/alteração de um .xls já existente.

hheheheheehheehehehe
sei q eh meio chato, mas jah estou a 4 dias em cima disso eu fui obrigado a apelar pra v6.
heehhe

várias cabeças pensam melhor que uma!

:D

eh galerinha, ta dificil, sera q mais alguem teria ideia sobre isso, talvez trabalhar com o METODO COM() atravez de servidores WINDOWS
???

sera q algume teria alguma sugestao para trabalhar com metodo COM() do windows

ouvi rumores dizendo que é possivel fazer a alteração da maneira como quero

mas ainda nao achei alguma referencia para trabalhar.
<?php
$nome = "Flávio Rodrigues";
$site = "http://www.expresso.com.br";
$idade = "21";
?>

nada é uma palavra esperando tradução...




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq