How to create an Excel file using Nodejs? Inserting audio How to insert audio into html.

I'm a nodejs programmer. Now I have a table of data that I want to save into an Excel file. How can I do it?

I found several node libraries. But most of them are Excel parsers, not Excel writers. I use Linux server. Hence, you need something that can run on Linux. Please let me know if there are any useful libraries you know of.

or is there a way to convert a csv file to an xls file (programmatically)?

7 55

Geeky_monster

7 answers:

Works with CSV and XLSX formats.

Great for reading/writing XLSX streams. I used it to stream XLSX into an Express response object, basically like this:

App.get("/some/route", function(req, res) ( res.writeHead(200, ( "Content-Disposition": "attachment; filename="file.xlsx"", "Transfer-Encoding": " chunked", "Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" )) var workbook = new Excel.stream.xlsx.WorkbookWriter(( stream: res )) var worksheet = workbook.addWorksheet(" some-worksheet") worksheet.addRow(["foo", "bar"]).commit() worksheet.commit() workbook.commit() )

works great for large files, performs much better than excel4node (got huge memory usage and node process "out of memory" crashing after almost 5 minutes for a file containing 4 million cells in 20 sheets) since its threading capabilities are much more limited (doesn't allow "commit()" " data to extract chunks as soon as they can be generated)

Hello, dear blog readers. It is not surprising that media sites have become increasingly popular lately. On such sites it is very interesting, for example you can watch some video or listen to great music. But this time we will listen to music, namely, we will learn how to insert audio files into our website using HTML5.

As it turns out, HTML5 supports audio tags, making it very easy to insert music into a website. It's true that not all older browsers play the audio file, but all modern browsers they do it with a bang.

Demo Browser support

All browsers that support the tag are IE9+, Chrome, Opera, Safari and Firefox. But there is one more nuance: not all browsers support all audio formats.

For example: IE9+ only supports mp3 files, but does not support wav and ogg.

Chrome after version 6 supports almost all formats.

Opera 10+ does not support mp3, honestly, it seems to me that this is its very big drawback, it does not support such a popular format. But it works great with wav and ogg.

WITH Firefox browser the same story as with Opera. For this she has a huge and fat minus.

Safari supports all audio formats except ogg.

Adding an audio file to the site

To add an audio file to your site, you need to include a direct link to the file between the tags. The link is indicated using the tag. This is what the finished code will look like:

As you can see, 3 files have been added here at once, so if some browser does not support mp3, it will automatically play the format that it does, and so on.

And if the browser does not support the tag at all, then this message “Your browser does not support audio” will pop up.

But we are kind people :-) And if the user cannot listen to the music, we will let him download it. To do this, you just need to add links to the files. Thus we will get the following code:

Your browser does not support audio

Title, Title, Title

This way the user can download the file :-)

Friends, here is an example of our work. A simple player is installed by the browser itself.

Demo

That's all, dear friends. If you have any questions or difficulties, ask in the comments. See you soon.

This question comes up very often, so I decided to devote a separate article to it in the lessons. Since HTML does not have a universal technology for playing audio for all browsers, to solve this problem I suggest downloading the audio player file, as is done on most sites. We do everything step by step:

1. On the hosting where your site is located, in the root directory (the folder where the index file is), create the audio folder. In the future you will place all audio files into it.

3. Now select necessary files, better in mp3 format. Create an audio folder in the root of the site and upload them.

4. All that remains is to insert the player connection code. It is suitable for any site. In the right place, you just need to indicate the path to the player file and audio file, respectively replacing the words your_domain and audio_file name:






And everything is ready! You can also look at the working example.

How to install background music in html Using the capabilities of HTML and the browser, you can also insert background music into the page. You will need an audio file in the desired format: WAV, AU, MIDI or MP3. You can use any file with the specified extension as an example.

The first way is the embed tag. The embed element is used to load and display objects (for example, video files, flash movies, some sound files etc.) that the browser does not initially understand.

The syntax is quite simple:

A closing tag is not required.

Now look at an example of a record with attributes, and below with their decoding:

Embed tag attributes for playing audio in html
width - panel width in pixels (or percentage)
height - panel height in pixels (or percentage)
align - position of the panel relative to the text, possible values ​​are left, right, center
hidden - allows you to hide the panel, attribute values: true - the panel is hidden, false - the panel is visible (default value)
autostart - true - the player starts automatically when the page loads, false - waits for the play button to be pressed
loop - loop, true - the track is played in a circle, and if false - only once

Second way.


Very old, but also practical) Add the melody to the same folder (directory) where your file is located, and in the body write the following code:

As a result, after loading the page, the melody you specified in the bgsound tag will sound. Now let's take a better look at the tag attributes:
src - path to your audio file
loop - how many times to repeat the melody (if -1, then repeats endlessly)
balance - stereo balance value (from -10000 to 10000)

volume - melody playback volume, where 0 is the maximum, and -10000 is the minimum.

However, there will be no way to control the player in any way - every time the page is refreshed, the track will be played again.

After describing the method of inserting background music, I want to dissuade you from this, since most users, as a rule, already listen to music when they visit various sites. Therefore, accompanying music can only force him to close the tab with the site.
Inserting audio and music in HTML5 - audio tag

audio - a paired tag that defines background sound, music or other audio stream on the site.

Audio tag attributes
autoplay - the file is played immediately when the page is loaded (similar to bgsound background music)
controls - display the player control panel in the browser
preload - the audio file will be loaded along with the page loading
src - path to the audio file (mp3 or ogg)

Example code with audio tag





Audio tag


Audio in HTML 5





The audio tag is not supported by your browser.
Download music.


Music on the site is more a rarity than the norm. When inserting music onto a website, you need to understand that some users may be completely turned off by it. In this article we will look at several options for inserting music into a website, and also look at how to make background music.

How to insert background music on a website

Inserting background music on a website is the most dangerous option in terms of losing visitors. Because the background music not only cannot be turned off, but its volume cannot be adjusted in any way (it all depends on the current volume on the computer). So you need to think a hundred times before inserting background music.

There are two ways to insert music into html

Option 1. Via html tag Syntax for inserting background music

The tag has several attributes:

  • loop="value" - the number of repetitions of the music (if -1, then repeats endlessly)
  • balance="value" - stereo balance (from -10000 to 10000)
  • volume="value" - volume (0 maximum, -10000 minimum)

Music will play automatically when the page loads.

For example

Option 2. Using the Syntax tag for inserting an object with music

The tag can use the following attributes:

  • width="value" - width (in pixels or percentages)
  • height="value" - height (in pixels or percentage)
  • align="value" - alignment (left - left, right - right, center - center)
  • hidden="value" - panel visibility (true - hide, false - show), by default the panel is visible
  • autostart="value" - play music when loading (true - yes, false - no)
  • loop="value" - value true - play in a circle, false - once

For example

The standard player will look different for each browser, so we will not consider each of them separately.

In html5 you can use the tag

The meaning of using the tag is questionable, since older browsers still do not support html5.

Tag syntax Browser does not support audio

The following attributes can be used:

  • autoplay="value" - turn on music immediately when the page loads
  • controls="value" - display the player control panel in the browser
  • loop="value" - responsible for cyclicity
  • preload="value" - load music immediately when the page loads

The considered options, in my opinion, are not ideal solutions, since they are all based on standard players. Each browser will have its own default player, and in some it may not work at all. Therefore, it is best to download the player to your website and download music from it. Such a player will have functions for stopping, adjusting volume, etc. - all the necessary set for a simple user.

Description

Adds, plays, and manages audio settings on a web page. The path to the file is specified via the src attribute or a subtag. You can write text inside the container that will be displayed in browsers that do not work with this tag.

The list of codecs supported by browsers is limited and is given in table. 1.

Table 1. Codecs and browsers
Codec Internet Explorer Chrome Opera Safari Firefox
ogg/vorbis
wav
mp3
A.A.C.

For universal playback in specified browsers, audio is encoded using different codecs and files are added simultaneously through the tag.

Syntax Attributes The sound starts playing immediately after the page loads.

Adds a control panel to an audio file.

Repeats the sound from the beginning after it ends.

Used to download a file along with loading a web page.

Specifies the path to the file being played.

Closing tag

Required.

HTML5 IE 8 IE 9+ Cr Op Sa Fx

audio

Alexander Klimenkov - Fourteen

The audio tag is not supported by your browser.