[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: PHP to Excel
Skesh
Доброго времени суток, разбираюсь с основами работы с COM-объектами, я знаю тема уже заездженая, но не нашел походящего ответа ни на форуме ни в гугле, суть проблемы такова - есть код:
<?php
$xls = new COM("Excel.Application"); // Создаем новый COM-объект
$xls->Application->Visible = 0; // Заставляем его отобразиться
$xls->Workbooks->Open("main.xls"); // Открываем ранее сохраненный документ

$range=$xls->Range("M9"); // Выбрали ячейку М9
$range->Value = "Проба записи"; // Вставили значение

// Сохраняем документ

$xls->Workbooks[1]->SaveAs("newmain.xls");

$xls->Quit(); //Закрываем приложение
$xls->Release(); //Высвобождаем объекты
$xls = Null;
$range = Null;
echo "Чтото случилось";
?>

пытаюсь вставить значения в файл и сохранить его под другим именем, есть директория test в ней файлы main.xls и index.php в котором и записан даный код. Ниче не далет тока выдает код ошибок:

Warning: (null)(): Invoke() failed: Ошибка. Source: Microsoft Office Excel Description: Не удалось найти 'main.xls'. Проверьте задание имени и местоположения файла. При попытке открытия файла с использованием списка недавно использованных файлов из меню ''Файл'' убедитесь, что файл не был переименован, перемещен или удален. in z:\home\localhost\www\test\index.php on line 4

Warning: (null)(): Invoke() failed: Ошибка. Source: Unavailable Description: Unavailable in z:\home\localhost\www\test\index.php on line 6

Warning: (null)(): Invoke() failed: Ошибка. Source: Unavailable Description: Unavailable in z:\home\localhost\www\test\index.php on line 10
Es!


пробывал прописовать полный путь - записавает значение в нужную ячейку с вот таким форматированием: РџСЂРѕР±Р° записи, и не копирует документ.

выдает ошибку:
Warning: (null)(): Invoke() failed: Ошибка. Source: Microsoft Office Excel Description: Ошибка доступа к документу 'main.xls', допускающему доступ только для чтения. in z:\home\localhost\www\test\index.php on line 10
Es!

Мне все что нужно это в готовый отфарматированый xls документ, в нужную ячейку вставить значение и скпировать его под другим именем, помогите пожалуйсто!



Спустя 32 минуты, 9 секунд (8.11.2011 - 20:50) walerus написал(а):
По коду ругается же что не может найти файл
Цитата
Не удалось найти 'main.xls'
, путь верен ? файл есть ?

Спустя 2 минуты, 51 секунда (8.11.2011 - 20:53) Игорь_Vasinsky написал(а):
Цитата
Проба записи

у тя походу с кодировкой не лады, в пути к файлу есть директории на кирилице?

Спустя 6 минут, 39 секунд (8.11.2011 - 21:00) Skesh написал(а):
Цитата (walerus @ 8.11.2011 - 17:50)
По коду ругается же что не может найти файл
Цитата
Не удалось найти 'main.xls'
, путь верен ? файл есть ?

файл есть, я кое как разобрался, кодировку excel документа преобразовал в 1251 а сам РНР файл преобразовал в анси, вроде как работает, но не понятно куда сохраняет.

Спустя 7 минут, 53 секунды (8.11.2011 - 21:08) Skesh написал(а):
Всем спасибо, сам разобрался, знач что я сделал, мож кому пригодится:
1. Сам index.php преобразовал в ANSI
2. теперь main.xls Сервис - Парамерты - Параметры веб документа - кодировка - Windows 1251
3.:
<?php
$xls = new COM("Excel.Application"); // Создаем новый COM-объект
$xls->Application->Visible = 0; // Заставляем его отобразиться
$xls->Workbooks->Open("d:\main.xls"); // Открываем ранее сохраненный документ (полный путь)

$range=$xls->Range("M9"); // Выбрали ячейку A1
$range->Value = "Проба записи1"; // Вставили значение

// Сохраняем документ

$xls->Workbooks[1]->SaveAs("d:\\newmain2.xls"); // полный путь, важно чтобы была двойная черта. d:\\newmain2.xls

$xls->Quit(); //Закрываем приложение
$xls->Release(); //Высвобождаем объекты
$xls = Null;
$range = Null;
echo "Es!";
?>

Спустя 7 месяцев, 21 день, 8 часов, 55 минут, 29 секунд (30.06.2012 - 06:03) 5201yh написал(а):
About Columbia Records
One of the most respected and successful record labels in the world, Columbia Records is home to established superstars and exciting new talent. Columbia Records is a wholly-owned subsidiary of Sony Music Entertainment.
About Syco
Syco Entertainment is a leading global music, television, film and digital production company. Syco is a joint venture between Simon Cowell and Sony Music Entertainment, with offices in London and Los Angeles. Syco's television and music assets include leading global franchises The X Factor and Got Talent, as well as artists such as Leona Lewis, Susan Boyle, Il Divo, Cher Lloyd, One Direction & Labrinth. About Sony Music Entertainment Sony Music Entertainment is a global recorded music company with a current roster that includes a broad array of both local artists and international superstars. The company boasts a vast catalog that comprises some of the most important recordings in history. It is home to premier record labels representing music from every genre, including American Recordings, Arista Nashville, Beach Street Records, BNA Records, Columbia Nashville, Columbia Records, Day 1, Epic Records, Essential Records, Flicker Records, Kemosabe Records,Boss BV8966BPioneer DEH-P7400HDPioneer DEH-3300UB LaFace Records, Legacy Recordings, MASTERWORKS, Polo Grounds, RCA Records, RCA Nashville, RCA Red Seal, Reunion Records, Roc Nation, Sony Classical, Sony Music Latin, Star Time International, Syco Music, Verity Gospel Music Group, and Volcano Entertainment. Sony Music Entertainment is a wholly owned subsidiary of Sony Corporation of America.

Спустя 2 дня, 5 часов, 32 минуты, 21 секунда (2.07.2012 - 11:35) Guest написал(а):

The in-dash receiver features the first 7-inch capacitive touchscreen, designed specifically for easier in-vehicle operation. Compatible with more than 80% of the smartphones in use today1, AppRadio 2 works with more than 15 of the most popular Android smartphone devices2, with iPhone 4 and iPhone 4S, and with more than two dozen apps ranging from navigation to entertainment. JVC KDR530Clarion CX501JVC Bluetooth In-Dash Digital Media Receiver with developers to release in-vehicle friendly apps and will demonstrate several Android third party apps at the show, including echoecho?, Inrix?, Extra Mile? and Best Parking?.
Pioneer is also unveiling its dedicated app developer portal, www.buycardvdplayer.com, to encourage third party development of compatible AppRadio apps. The self-service website will provide developers with the procedures for submitting their apps for consideration, as well as the AppRadio software development kit (SDK) for qualifying apps. CEA Booth #54 – Pioneer Home Electronics Division
Pioneer’s Home Electronics Division continues to develop products with the most connectivity options for today’s smart devices. Its new SMA series of Wi-Fi? speakers and Pioneer and Elite? branded audio video receivers make it extremely easy for consumers to connect their personal devices using wireless technologies such as Apple’s Airplay?, DLNA? 1.5, Bluetooth?, Wireless Direct and HTC Connect?.


_____________
*пускает слюну, глядя на код* :)
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.