C++ Builder
| Главная | Уроки | Статьи | FAQ | Форум | Downloads | Литература | Ссылки | RXLib | Диски |

 
OLE EXELL, cохранение HTM
** Jack
Отправлено: 08.07.2004, 15:00


Не зарегистрирован







Кто знает как из СBuilder через OLE сохранить файл exel
в виде htm,
по аналогии "СОХРАНИТЬ КАК WEB СТРАНИЦУ" в EXEL.
Guest
Отправлено: 08.07.2004, 15:42


Не зарегистрирован







Метод книги Save as формат файла xlHTML. Help можно смотреть Excel->Visual_Basic->Help.
** Jack
Отправлено: 09.07.2004, 07:36


Не зарегистрирован







Sorry
но что-то я ничего не нашел из описания сохранения в виде HTM
** Jack
Отправлено: 09.07.2004, 08:28


Не зарегистрирован







Я делаю вот таким образом:
//-------------------------------------------------------
app.OlePropertySet("DisplayAlerts", false);
app.OlePropertyGet("WorkSheets",1).OleProcedure("SaveAs","c:\\test.xls")
app.OlePropertyGet("WorkBooks",1).OleProcedure("Close");
//--------------------------------------------------------

На выходе получается файл test.xls
А может кто знает как сразу импортировать в HTML ?

AVC
Отправлено: 09.07.2004, 09:20


Ветеран

Группа: Модератор
Сообщений: 1583



Примерно так (как вам писал гость)
app.OlePropertyGet("WorkSheets",1).OleProcedure("SaveAs","c:\\test.xls", xlHTML)
Синтаксис требует уточнения

Выдержка из Help'а
CODE

Saves changes to the sheet (Syntax 1) or workbook (Syntax 2) in a different file.

Syntax 1

expression.SaveAs(Filename, FileFormat, Password, WriteResPassword, ReadOnlyRecommended, CreateBackup, AddToMru, TextCodePage, TextVisualLayout)

Syntax 2

expression.SaveAs(Filename, FileFormat, Password, WriteResPassword, ReadOnlyRecommended, CreateBackup, AccessMode, ConflictResolution, AddToMru, TextCodePage, TextVisualLayout)

expression Required. An expression that returns a Chart or Worksheet object (Syntax 1) or a Workbook object (Syntax 2).

Filename Optional Variant. A string that indicates the name of the file to be saved. You can include a full path; if you don’t, Microsoft Excel saves the file in the current folder.

FileFormat Optional Variant. The file format to use when you save the file. For a list of valid choices, see the FileFormat property. For an existing file, the default format is the last file format specified; for a new file, the default is the format of the version of Excel being used.

Password Optional Variant. A case-sensitive string (no more than 15 characters) that indicates the protection password to be given to the file.

WriteResPassword Optional Variant. A string that indicates the write-reservation password for this file. If a file is saved with the password and the password isn’t supplied when the file is opened, the file is opened as read-only.

ReadOnlyRecommended Optional Variant. True to display a message when the file is opened, recommending that the file be opened as read-only.

CreateBackup Optional Variant. True to create a backup file.

AccessMode Optional Variant. The workbook access mode. Can be one of the following XlSaveAsAccessMode constants: xlShared (shared list), xlExclusive (exclusive mode), or xlNoChange (don’t change the access mode). If this argument is omitted, the access mode isn’t changed. This argument is ignored if you save a shared list without changing the file name. To change the access mode, use the ExclusiveAccess method.

ConflictResolution Optional Variant. Specifies the way change conflicts are resolved if the workbook is a shared list. Can be one of the following XlSaveConflictResolution constants: xlUserResolution (display the conflict-resolution dialog box), xlLocalSessionChanges (automatically accept the local user’s changes), or xlOtherSessionChanges (accept other changes instead of the local user’s changes). If this argument is omitted, the conflict-resolution dialog box is displayed.

AddToMru Optional Variant. True to add this workbook to the list of recently used files. The default value is False.

TextCodePage Optional Variant. Not used in U.S. English Microsoft Excel.

TextVisualLayout Optional Variant. Not used in U.S. English Microsoft Excel.



Отредактировано AVC — 09/07/2004, 09:24
** Jack
Отправлено: 09.07.2004, 14:32


Не зарегистрирован







Вот интересно как-то получается если я ставлю
Примерно так (как вам писал гость)
app.OlePropertyGet("WorkSheets",1).OleProcedure("SaveAs",file, 1);
cсохраняется как Excel
если ставлю 2 то как .txt
app.OlePropertyGet("WorkSheets",1).OleProcedure("SaveAs",file, 2);
если ставлю 3 то как , то еще какой-то формат
и т.д. до 11.
Может есть какой-то код для HTML ?

Но если я пишу
app.OlePropertyGet("WorkSheets",1).OleProcedure("SaveAs",file, xlHTML);
Выдается сразу ошибка.
Как с этим бороться?

Guest
Отправлено: 09.07.2004, 14:42


Не зарегистрирован







xlHTML = 44 если не ошибаюсь....
AVC
Отправлено: 09.07.2004, 15:13


Ветеран

Группа: Модератор
Сообщений: 1583



excel_2k.h из комплнкта поставки Builedr'а или Delphi
CODE

typedef enum XlFileFormat
{
 xlAddIn = 18,
 xlCSV = 6,
 xlCSVMac = 22,
 xlCSVMSDOS = 24,
 xlCSVWindows = 23,
 xlDBF2 = 7,
 xlDBF3 = 8,
 xlDBF4 = 11,
 xlDIF = 9,
 xlExcel2 = 16,
 xlExcel2FarEast = 27,
 xlExcel3 = 29,
 xlExcel4 = 33,
 xlExcel5 = 39,
 xlExcel7 = 39,
 xlExcel9795 = 43,
 xlExcel4Workbook = 35,
 xlIntlAddIn = 26,
 xlIntlMacro = 25,
 xlWorkbookNormal = 0xFFFFEFD1,
 xlSYLK = 2,
 xlTemplate = 17,
 xlCurrentPlatformText = 0xFFFFEFC2,
 xlTextMac = 19,
 xlTextMSDOS = 21,
 xlTextPrinter = 36,
 xlTextWindows = 20,
 xlWJ2WD1 = 14,
 xlWK1 = 5,
 xlWK1ALL = 31,
 xlWK1FMT = 30,
 xlWK3 = 15,
 xlWK4 = 38,
 xlWK3FM3 = 32,
 xlWKS = 4,
 xlWorks2FarEast = 28,
 xlWQ1 = 34,
 xlWJ3 = 40,
 xlWJ3FJ3 = 41,
 xlUnicodeText = 42,
 xlHtml = 44
} XlFileFormat;
** Jack
Отправлено: 09.07.2004, 16:33


Не зарегистрирован







УРА
Спасибо всем , получилось.
Это действительно 44
Сохраняется как .HTM

Вернуться в Вопросы программирования в C++Builder