1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
#Define xlCenter -4108 #Define xlSolid 1 #Define xlEdgeLeft 7 #Define xlEdgeTop 8 #Define xlEdgeBottom 9 #Define xlEdgeRight 10 #Define xlInsideVertical 11 #Define xlInsideHorizontal 12 #Define xlThin 2 #Define xlThick 4 #Define xlMedium -4138 #Define xlDouble -4119 Local lcPath, loExcel, lnRow loExcel = Createobject("Excel.Application") With loExcel .Visible = .T. .WorkBooks.Add **.ActiveWindow.DisplayZeros = .F. * Устанавлиаем ширину столбцов .Columns[1].ColumnWidth = 5 .Columns[2].ColumnWidth = 40 .Columns[3].ColumnWidth = 10.71 .Columns[4].ColumnWidth = 15 .Columns[5].ColumnWidth = 15 .Columns[6].ColumnWidth = 15 .Columns[7].ColumnWidth = 15 .Columns[8].ColumnWidth = 15 .Columns[9].ColumnWidth = 15 * Заголовок .cells(1,3).Font.Size = 13 .cells(1,3).Font.Bold = .T. .cells(1,3).Value = 'Накопительная ведомость данных путевых листов по автомобилям' .cells(2,5).Font.Size = 11 .cells(2,5).Font.Bold = .F. .Range("A7:I7").Select .ActiveWindow.FreezePanes = .T. With .Selection .RowHeight = 18 .Font.Size = 10 .Font.Bold = .T. Endwith .cells(5,1).Value = '№ пп' .cells(5,2).Value = 'Наименование автомобиля, номер и дата путевого листа' .cells(5,3).Value = 'Единица измерения' .cells(5,4).Value = 'Остаток на начало отчетного периода' .cells(5,5).Value = 'Поступило' .cells(5,6).Value = 'Расход ' .cells(5,7).Value = 'Остаток на конец отчетного периода' .cells(5,8).Value = 'Показания спидометра на' .cells(6,8).Value = 'начало отчетного периода' .cells(6,9).Value = 'конец отчетного периода' *редактируем ячейки для дальнейшего использования .Range("A5:A6").Select With .Selection .MergeCells = .T. .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = .T. .Orientation = 0 .AddIndent = .F. .IndentLevel = 0 .ShrinkToFit = .F. .ReadingOrder = -5002 &&xlContext Endwith .Range("B5:B6").Select With .Selection .MergeCells = .T. .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = .T. .Orientation = 0 .AddIndent = .F. .IndentLevel = 0 .ShrinkToFit = .F. .ReadingOrder = -5002 Endwith .Range("C5:C6").Select With .Selection .MergeCells = .T. .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = .T. .Orientation = 0 .AddIndent = .F. .IndentLevel = 0 .ShrinkToFit = .F. .ReadingOrder = -5002 Endwith .Range("D56").Select With .Selection .MergeCells = .T. .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = .T. .Orientation = 0 .AddIndent = .F. .IndentLevel = 0 .ShrinkToFit = .F. .ReadingOrder = -5002 Endwith .Range("E5:E6").Select With .Selection .MergeCells = .T. .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter Endwith .Range("F5:F6").Select With .Selection .MergeCells = .T. .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter Endwith .Range("G5:G6").Select With .Selection .MergeCells = .T. .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = .T. .Orientation = 0 .AddIndent = .F. .IndentLevel = 0 .ShrinkToFit = .F. .ReadingOrder = -5002 Endwith .Range("H5:I5").Select With .Selection .MergeCells = .T. .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter Endwith .Range("H6:H6").Select With .Selection .MergeCells = .T. .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = .T. .Orientation = 0 .AddIndent = .F. .IndentLevel = 0 .ShrinkToFit = .F. .ReadingOrder = -5002 Endwith .Range("I6:I6").Select With .Selection .MergeCells = .T. .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = .T. .Orientation = 0 .AddIndent = .F. .IndentLevel = 0 .ShrinkToFit = .F. .ReadingOrder = -5002 Endwith .Range("A5:I6").Select With .Selection .BorderS(xlEdgeLeft).Weight = xlMedium .BorderS(xlEdgeTop).Weight = xlMedium .BorderS(xlEdgeBottom).Weight = xlMedium .BorderS(xlEdgeRight).Weight = xlMedium .BorderS(xlInsideVertical).Weight = xlThin .BorderS(xlInsideHorizontal).Weight = xlThin .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter Endwith .Rows("6:6").RowHeight = 45 .cells(7,1).NumberFormat = "@" .cells(7,1).Value = "1" .cells(7,2).NumberFormat = "@" .cells(7,2).Value = "2" .cells(7,3).NumberFormat = "@" .cells(7,3).Value = "3" .cells(7,4).NumberFormat = "@" .cells(7,4).Value = "4" .cells(7,5).NumberFormat = "@" .cells(7,5).Value = "5" .cells(7,6).NumberFormat = "@" .cells(7,6).Value = "6" .cells(7,7).NumberFormat = "@" .cells(7,7).Value = "7" .cells(7,8).NumberFormat = "@" .cells(7,8).Value = "8" .cells(7,9).NumberFormat = "@" .cells(7,9).Value = "9" *делаем сквозную строку With .ActiveSheet.PageSetup .PrintTitleRows = "$7:$7" .PrintTitleColumns = "" EndWith .Range("A7:I7").Select With .Selection .BorderS(xlEdgeLeft).Weight = xlMedium .BorderS(xlEdgeTop).Weight = xlMedium .BorderS(xlEdgeBottom).Weight = xlMedium .BorderS(xlEdgeRight).Weight = xlMedium .BorderS(xlInsideVertical).Weight = xlThin .BorderS(xlInsideHorizontal).Weight = xlThin .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter Endwith lnRow = 7 *тут заполняем таблицу своими данными .Range(.cells(8,1),.cells(lnRow, 9)).Select With .Selection .BorderS(xlEdgeLeft).Weight = xlMedium .BorderS(xlEdgeTop).Weight = xlMedium .BorderS(xlEdgeBottom).Weight = xlMedium .BorderS(xlEdgeRight).Weight = xlMedium .BorderS(xlInsideVertical).Weight = xlThin .BorderS(xlInsideHorizontal).Weight = xlThin .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter Endwith lnRow = lnRow + 2 .cells(lnRow,2).NumberFormat = "@" .cells(lnRow,2).Value = "Отчет проверил _______________________________________________________________________" Endwith Messagebox ('Данные выгружены в программу Excel',0+48,; 'Сообщение программы') |
Я ищу, чтобы экспортировать таблицу из Visual Foxpro 5.0, чтобы преуспеть с итогом для одного столбца. Я знаю, что вы можете рассчитать сумму (столбец), но я не знаю, как включить это в экспорт.
2018-02-16 16:33
4
ответа
Решение
Я знаю, что вы можете рассчитать сумму (столбец), но я не знаю, как включить это в экспорт
Короткий ответ: ты не можешь.
Вы можете использовать команду VFP: COPY TO файл Excel XL5 для вывода данных в указанный файл Excel, но вычисленные значения не будут включены.
НО, после того как вы записали данные, вы можете использовать VFP Automation of Excel, чтобы либо записать вычисленное значение в определенную ячейку, либо вы можете запустить Excel для вычисления и поместить результат в указанную ячейку.
Если вы еще не сделали VFP Automation of Excel, вам может потребоваться Google для этого, поскольку он включает в себя ряд команд, которые должны варьироваться в зависимости от ваших конкретных потребностей.
Удачи
2018-02-16 17:15
Если вам это нужно в Excel, тогда зачем вообще использовать sum? Excel умеет суммировать. Если вам действительно нужно, вы можете сделать это, просто создав курсор с добавленной строкой для хранения суммы. Что-то вроде:
select f1, f2, f3 from myTable ;
union all ;
select '', '', sum(f3) as f3 ;
from myTable group by 1,2
Создание данных Excel из курсора / таблицы — более сложная часть, но есть много способов (то есть: просто копирование в виде файла с разделителями с заголовком, который вы создаете.CSV, который затем можно открыть с помощью Excel). ИМХО одним из лучших способов является передача данных с использованием набора записей ADO. Вы можете искать код VFP2Excel в Интернете. Я написал и опубликовал много ее вариантов (я добавлю ссылку, если скоро ее найду — для VFP5 могут потребоваться небольшие изменения для команды функций, недоступной в VFP5).
(Или вы можете сделать это другим способом и напрямую получить данные из Excel, используя ADO — QueryTables).
OK нашел много ссылок, некоторые из них:
Vfp2Excel обсуждение
Автоматизация Excel на fox.wikis
Еще один
2018-02-16 20:25
Я подумал о другом способе получить вычисленную сумму в файл Excel, но это своего рода «кладж», и в файле Excel это действительно не будет динамический расчет, а вместо этого будет ячейка, которая может статически удерживайте вычисленное значение VFP.
Хорошо, вот «Kludge»….
Откройте таблицу данных VFP и выполните расчет итогов.
APPEND BLANK, чтобы добавить новую пустую запись, и в одном из полей ЗАМЕНИТЬ ее значение на рассчитанную сумму.
Теперь сделайте свой файл COPY TO Excel XL5
Все ваши данные будут записаны, и эти данные будут включать в себя рассчитанную итоговую запись с ее значением.
ПРИМЕЧАНИЕ. Если необходимо, чтобы строки Excel находились в последовательности, отличной от исходной таблицы данных VFP, перед запуском COPY TO… выполните запрос SQL, чтобы получить все записи в нужном порядке, и запишите результаты в новый стол / курсор переписать.
Затем вы должны добавить «Пустой бланк» к результирующей таблице / курсору и использовать его для «Копировать в…».
Удачи
2018-02-16 22:17
Вы можете использовать лист Excel в качестве шаблона. Затем заполните конкретные ячейки из FoxPro в этот шаблон и функции и форматирование в шаблоне будут работать с вашими данными.
lcExcelFile = "output.xls" && your ouput
oExcelObject = CREATEOBJECT('Excel.Application')
oExcelWorkbook = ;
oExcelObject.APPLICATION.Workbooks.OPEN(sDir + "" + "template.xls") && your template
oActiveExcelSheet = oExcelWorkbook.Worksheets("sheet").ACTIVATE
oExcelSheet = oExcelWorkbook.Worksheets("sheet")
WAIT WINDOW "Developing Microsoft Excel File..." + CHR(13) + "" + CHR(13) + ;
"Passing formatting information to Excel." + CHR(13) + "" NOWAIT
SELECT cTmp && your data table or cursor
GOTO TOP
oExcelSheet.Cells(1,1).VALUE = sTitle
nRow = 3 && moving past title
sNote = ""
DO WHILE NOT EOF()
nRow = nRow + 1
&& Insertint Records
oExcelSheet.Cells(nRow,1).VALUE = STR(cTmp.INlocx)
oExcelSheet.Cells(nRow,2).VALUE = ALLTRIM(cTmp.INacct) + '-' + ALLTRIM(cTmp.INmr_)
oExcelSheet.Cells(nRow,3).VALUE = ALLTRIM(cTmp.INpnam)
oExcelSheet.Cells(nRow,4).VALUE = ALLTRIM(cTmp.INCARR)
oExcelSheet.Cells(nRow,5).VALUE = ALLTRIM(cTmp.INADR1) + ALLTRIM(cTmp.INADR2)
oExcelSheet.Cells(nRow,6).VALUE = ALLTRIM(cTmp.INCITY)
oExcelSheet.Cells(nRow,7).VALUE = ALLTRIM(cTmp.INSTAT)
oExcelSheet.Cells(nRow,8).VALUE = STR(cTmp.INZIP)
oExcelSheet.Cells(nRow,9).VALUE = STR(cTmp.INAREA)
oExcelSheet.Cells(nRow,10).VALUE = STR(cTmp.INPHON)
oExcelSheet.Cells(nRow,11).VALUE = ALLTRIM(cTmp.INPOL_)
oExcelSheet.Cells(nRow,12).VALUE = ALLTRIM(cTmp.INGRP_)
oExcelSheet.Cells(nRow,13).VALUE = ALLTRIM(cTmp.INPOLH)
oExcelSheet.Cells(nRow,14).VALUE = STR(cTmp.INEFDT)
oExcelSheet.Cells(nRow,15).VALUE = STR(cTmp.INETDT)
oExcelSheet.Cells(nRow,16).VALUE = ALLTRIM(cTmp.INRELATE)
SELECT cTmp
SKIP
ENDDO
&&saving template AS output
oExcelWorkbook.SAVEAS(lcExcelFile)
oExcelObject.QUIT
RELEASE oExcelObject
2018-02-16 18:20
- Remove From My Forums
-
Question
-
I work for the NS Provincial Government and currently use Visual FoxPro 9.
Going forward, our Help Desk will no longer be supporting this program. We are also shifting to new software for our Correspondence Tracking System (CTS).
My question is: How do I transfer data from FoxPro to a useable (searchable) program like Excel or Word.
When I open the program, there are no features referring to exporting. The only thing that I can produce is a report of outstanding correspondence. I think that I need to know how to ‘get in through a back door’.
Can anyone help me?
Regards,
Joanne Bolger
Answers
-
Hi,
There is a command in Foxpro to copy data from VFP table to Excel file but it is having some limitations of MEMO field will not get transferred to excel file and limitation of records get exported to excel file (can export a maximum of 65,535 rows)
Extract from VFP 9 Help
COPY TO FileName [DATABASE DatabaseName [NAME
LongTableName]] [FIELDS FieldList | FIELDS LIKE Skeleton | FIELDS EXCEPT
Skeleton] [Scope] [FOR lExpression1] [WHILE
lExpression2] [ [WITH] CDX ] | [ [WITH] PRODUCTION ] [NOOPTIMIZE] [ [TYPE] [ FOXPLUS | FOX2X | DIF | MOD | SDF | SYLK | WK1 | WKS | WR1 | WRK | CSV | XLS | XL5 | DELIMITED [ WITH
Delimiter | WITH BLANK | WITH TAB | WITH CHARACTER Delimiter
] ] ] [AS nCodePage]It is better to go for customized package to export it to Excel.
— If you want to Only view/Search the data you can use Foxpro itself or application like DBFVIEWER
— You can also migrate VFP data to different database like MS-SQL, MYSQL, Postgres so that you can query data.
-
Marked as answer by
Wednesday, July 31, 2019 6:12 AM
-
Marked as answer by
-
Hi,
There is a command in Foxpro to copy data from VFP table to Excel file but it is having some limitations of MEMO field will not get transferred to excel file and limitation of records get exported to excel file (can export a maximum of 65,535 rows)
The limitation will depend of the Excel version you have installed
Each version have a maximum lines per sheet, and that will determine the maximum lines to be exported
You can always export it as CSV with no maximum lines limited and open it from Excel
-
Marked as answer by
Tom BorgmannEditor
Wednesday, July 31, 2019 6:12 AM
-
Marked as answer by
-
Since your actual need isn’t to get Excel files but the data, a Foxpro Application will either store it’s data in separate DBF (table) data files.
Unless these tables are encrypted you have all data in these files and access to it just needs Foxpro or at least the VFP OLEDB Provider and programming skills. Not exports and surely not exports to formats really bad for data transfer.
You’re talking of corrrespondence tracking and it seems to me all you really need to transfer are
a) current correspondence to be able to continue it until some final stage
b) old correspondence only for reference.
I second Tamar, it’s a data migration job to transfer this data to a target system and that’ll require knowledge about the structuring of the data in the old and new system and translation of the data in terms of transformation. Even the same topic and domain
of data like shop order/sales can be stored in gazillian of different ways and database of system A can have table structures storing aspects of the data System B has not foreseen, so you caould have a loss of details.The usual strategy is to cover a) by finishing such correspondence with the old system, then b) isn’t even necessarily moving any data into the format of a new system but you just keep it in some searchable form. Even if t’s a requirement to purge VFP and
VFP runtimes from your systems as laws or regulations demand that, you’d be better off with at least a 1:1 transferring of the data as it’s strucutred now into a MSSQL backend or whatever is allowed database server and have a query tool to get at whatever
back reference you need.In very short summary you’re likely having no idea what relational databases are and how data is stored in a relational way and normalized structure and that it doesn’t simply translate to one major list, even if the old VFP system mainly displayed a list
of correspondence to you.To illustrate that with eg mails of a mail client, which really is mainly just a list of the mail texts with all its attributes from sender to recipient, subject, date, etc. Several mails will belong to one «conversation» related by being replies
to each other. That kind of links are not really covered by an Excel sheet. So think twice before you go such a route of export of data in inferior formats not capable to give you even such simple features as grouping mails belonging to the same conversation.Bye, Olaf.
-
Edited by
OlafDoschke
Wednesday, May 15, 2019 5:35 AM -
Marked as answer by
Tom BorgmannEditor
Wednesday, July 31, 2019 6:14 AM
-
Edited by
-
Your screenshot dowsn’t show, it’s complicated to get the feature to post images here in this forum.
But from what you describe this isn’t FoxPro, it’s likely just an application written in FoxPro and of course that doesn’t give you all the options the development environment and the language has.
The developer of that application might nocht even have changed the main window title bar caption from «Microsoft Visual Foxpro» to somthing ekse like the application title and therefore you think this is FoxPro.
Let me show how the FoxPro environment looks like:
And this is just the bare minimum with VFP system menu, standard toolbar, command window (to immediately execute commands) and no project file open and none of the several tool windows you find in the menu and toolbar or other toolbars not added, as they
only are necessary while designing forms or classes or reports, etc. etc. VFP transforms it’s menu and toolbars depending on what you do, but even the bare minium is more than you describe and has nothing sepcialised such as letters.So if your window only has the menu items you tell, that’s not FoxPro.
What you likely will have is a folder with data, DBF files for sure — and as your menu items allow reindex, pack and especially pack memo — also CDX (index) and FPT (memo files). These three will come in bundles and are your data files.
It’s not straight forward to get at this data without Foxpro itself, but maybe what you start is indeed VFP, but just by configuration starting a _startup program, which replaces the system menu with the application menu.
Do you have an executable named VFPN.EXE where N might be any digit from 3 to 9? (It should be 9, when you say it is VFP9, but as you see the standard development environment of VFP doesn’t tell the version number)
If so, you might get far more out of this, because quite likely someone who doesn’t even set the screen caption also doesn’t know how to build an EXE and a setup and just installs VFP itself with his programs and forms for simplicity, as he manages to start
that like he does during development. That’d be against the end user license of VFP, but not your fault.So tell us, the name of the EXE you start, you likely have a Windows start menu item or a shortcut. Instead of double clicking it, click on it with the right mouse key and find (depending on what) properties or an option to open the folder with the application.
That’ll tell us more about what you really have there,Bye, Olaf.
PS: last not least: If you don’t have VFP itself, you still can get at the data itself because things like the VFP OLEDB provider are free to get and can be used to query data. It doesn’t work standalone, it at least needs a script written in some language,
but even without any programming environment installed, you have powershell to run something, for example. It’s too early to hand out some code before we know what you really have.-
Edited by
OlafDoschke
Monday, May 27, 2019 10:18 AM -
Marked as answer by
Tom BorgmannEditor
Wednesday, July 31, 2019 6:13 AM
-
Edited by
-
It seems to me that whoever is implementing your new system should have the responsibility for transferring your existing data to it. Have you asked them to do so?
Tamar
-
Proposed as answer by
Koen-P
Wednesday, May 15, 2019 11:39 AM -
Marked as answer by
Tom BorgmannEditor
Wednesday, July 31, 2019 6:11 AM
-
Proposed as answer by