在 Drupal 中从 Excel 中提取内容

发布于 2024-08-19 22:35:05 字数 427 浏览 6 评论 0 原文

我想提取 Excel 文件的内容并将其填充到新帖子(页面)中。我想保持行列关系。

例如:

sample.xls

名称 |年龄 |性别

A | 20 | MB

| 30| F

C | 40 | 40 M


在 Drupal (我想要的)

名称 |年龄 |性别

A | 20 | MB

| 30| F

C | 40 | 40 M

Drupal 中是否有任何模块可以执行此操作,或者我应该为其创建一个新模块?我希望有些 drupaler 遇到过这种情况:)

I want to extract the contents of a excel file and populate them in a new post( page) . I'd like to maintain the row-column relationship.

Ex:

sample.xls

Name | Age | Sex

A | 20 | M

B | 30 | F

C | 40 | M


In Drupal (the one which i want)

Name | Age | Sex

A | 20 | M

B | 30 | F

C | 40 | M

Is there any module in Drupal to do that or should I create a new one for it? I wish some drupaler came across this situation :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

や莫失莫忘 2024-08-26 22:35:05

根据我所知道的问题下面的评论,没有适合您想要执行的操作的模块。不幸的是,当您将 Excel 电子表格导出为 HTML 时,Excel 会将各种格式附加到结果中,而您可能不希望这样。一种技巧是将电子表格另存为 .csv 文件(逗号分隔值),然后使用实用程序将 CSV 文件转换为 HTML 表格,您可以将其粘贴到节点内容中。我没有使用此 Google 搜索结果集,但无论如何,不​​乏可以尝试的结果。

There's no module for what you want to do based on your comment below the question that I'm aware of. Unfortunately when you export an Excel spreadsheet to HTML Excel will attach all kinds of formatting to the result and you probably don't want that. One trick would be to save the spreadsheet as a .csv file (comma-separated values) and then use a utility to convert the CSV file into an HTML table that you can paste into your node content. I haven't used any of the utilities in this set of Google search results but there's no shortage of ones you can try, anyway.

提赋 2024-08-26 22:35:05

尝试 FeedAPI 模块,它能够解析 CSV 文件,并且您可以将数据分配给特定字段,应该做你所需要的。

Try the FeedAPI module, it is able to parse CSV files, and you can assign data to specific fields, should do exactly what you need.

吃兔兔 2024-08-26 22:35:05

我认为这个旧的讨论包含您需要的资源。

I think this old discussion contains the resource you need.

只是偏爱你 2024-08-26 22:35:05

我确信有更好的方法来使用这个库,但在紧要关头我下载了 http: //code.google.com/p/php-excel-reader

然后在常规 drupal 节点中使用 php 过滤器并写入

<?php
error_reporting(E_ALL ^ E_NOTICE);
require_once 'path/to/excel/library/excel_reader2.php';
$data = new Spreadsheet_Excel_Reader("path/to/uploaded/spreadsheet/myexcelsheet.xls");
echo $data->dump($row_numbers=false,$col_letters=false,$sheet=0,$table_class='excel');
?>

http://code.google.com/p/php-excel-reader/wiki/Documentation

I'm sure there's a better way to use this library, but in a pinch I downloaded http://code.google.com/p/php-excel-reader

and then used the php filter in a regular drupal node and wrote

<?php
error_reporting(E_ALL ^ E_NOTICE);
require_once 'path/to/excel/library/excel_reader2.php';
$data = new Spreadsheet_Excel_Reader("path/to/uploaded/spreadsheet/myexcelsheet.xls");
echo $data->dump($row_numbers=false,$col_letters=false,$sheet=0,$table_class='excel');
?>

There are other options at http://code.google.com/p/php-excel-reader/wiki/Documentation

两仪 2024-08-26 22:35:05

我正在使用 Importer 进行上传... Importer 模块提供了以下提示:

*要启用对 .xls 文件的支持,请从此处下载“excel_reader2.inc”文件并将其放置在模块目录中。*

上面的“此处”指向:http://code.google.com/p/php-excel-reader/

将文件从 excel_reader2.php 重命名为 excel_reader2.inc并将其拖到 module/importer 文件夹中。就是这样..它可以让您直接上传 xls 文件并将其转换为 cvs。公式的其余部分只是 CSS 或您用来根据需要显示它的任何内容。

I'm using Importer for uploads... The Importer module provides this tip:

*To enable the support for .xls files download the "excel_reader2.inc" file from here and place in the module directory.*

The "here" in the above points to: http://code.google.com/p/php-excel-reader/

Rename the file from excel_reader2.php to excel_reader2.inc and drag it into the modules/importer folder. That's it.. it'll let you upload xls files directly and convert them to cvs for you. The rest of the formula is just CSS or whatever you're using to display it like you require.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文