Excel minangka alat sing kuat sing digunakake kanggo ngatur lan nganalisa data. Amarga umume dikenal kanggo fitur manipulasi angka lan data, uga nawakake akeh alat format lan presentasi sing migunani. Salah siji alat kasebut yaiku kemampuan kanggo nglebokake watermark, sing bisa digunakake kanggo nambah gambar latar mburi utawa teks menyang lembar kerja Excel. Watermark migunani kanggo nambah unsur merek menyang dokumen, nuduhake status utawa versi dokumen, utawa kanggo nambah lapisan pangayoman marang salinan utawa distribusi sing ora sah. Ing artikel iki, kita bakal njelajah carane nambah lan mbusak watermarks ing Excel nggunakake C#, nyedhiyakake pandhuan langkah-langkah kanggo sing pengin nambah daya tarik visual dokumen Excel lan nglindhungi konten sing penting.
- Excel Watermark API
- Tambah Watermark menyang Excel nggunakake C#
- Mbusak Excel Watermark nggunakake C#
- Setel Gambar Latar Excel nggunakake CURL Commands
Excel Watermark API
Aspose.Cells Cloud nyedhiyakake cara sing gampang lan efisien kanggo nggarap dokumen Excel ing awan, ngidini sampeyan nyepetake alur kerja lan ngotomatisasi akeh tugas sing gegandhengan karo Excel. Amarga kompatibilitas lintas-platform, integrasi sing lancar, keamanan sing kuat, lan efektifitas biaya, iku pilihan sing apik banget kanggo nggarap file Excel ing awan. Salajengipun, API kuat iki ngidini sampeyan nindakake macem-macem operasi ing dokumen Excel kanthi program, kalebu nambah lan mbusak tandha banyu.
Saiki, kanggo nyisipake watermark ing Excel nggunakake C# .NET, kita kudu nambah referensi Aspose.Cells Cloud SDK kanggo .NET ing proyek kita. Mulane, goleki Aspose.Cells-Cloud ing manajer paket NuGet lan klik tombol “Tambah Paket”. Salajengipun, kita uga kudu nggawe akun liwat Dashboard nggunakake alamat email sing bener.
Tambah Watermark menyang Excel nggunakake C#
Ayo goleki kanthi cepet ing potongan kode C# .NET kanggo nambah watermark menyang buku kerja Excel.
// Kanggo conto lengkap lan file data, bukak
https://github.com/aspose-cells-cloud/aspose-cells-cloud-dotnet/
// Entuk kredensial klien saka https://dashboard.aspose.cloud/
string clientSecret = "4d84d5f6584160cbd91dba1fe145db14";
string clientID = "bb959721-5780-4be6-be35-ff5c3a6aa4a2";
// nggawe conto CellsApi nalika ngliwati ClientID lan ClientSecret
CellsApi cellsInstance = new CellsApi(clientID, clientSecret);
// Input buku kerja Excel saka drive lokal
string input_Excel = "input.xls";
// Gambar sing bakal digunakake minangka tandha banyu
string imageFile = "Landscape.jpg";
// maca gambar input kanggo stream Kayata
var imageStream = System.IO.File.OpenRead(imageFile);
try
{
// Waca buku kerja Excel lan upload menyang panyimpenan maya
cellsInstance.UploadFile(input_Excel, File.OpenRead(input_Excel));
// Nggawe instance memoryStream
var memoryStream = new MemoryStream();
// Gunakake cara .CopyTo () lan nulis filestream saiki kanggo stream memori
imageStream.CopyTo(memoryStream);
// Ngonversi Stream menyang Array
byte[] imageBytes = memoryStream.ToArray();
// Tambah watermark menyang buku kerja Excel
var response = cellsInstance.CellsWorkbookPutWorkbookBackground(input_Excel, imageBytes, null);
// print pesen sukses yen concatenation sukses
if (response != null && response.Equals("OK"))
{
Console.WriteLine("Excel Watermark operation successful !");
Console.ReadKey();
}
}
catch (Exception ex)
{
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
Ing ngisor iki rincian cuplikan kode ing ndhuwur:
CellsApi cellsInstance = new CellsApi(clientID, clientSecret);
Nggawe obyek CellsApi nalika menehi kredensial klien minangka argumen.
var imageStream = System.IO.File.OpenRead(imageFile);
Waca gambar input menyang conto FileStream.
cellsInstance.UploadFile(input_Excel, File.OpenRead(input_Excel));
Unggah input Excel menyang panyimpenan maya.
var memoryStream = new MemoryStream();
imageStream.CopyTo(memoryStream);
byte[] imageBytes = memoryStream.ToArray();
Input FileStream diowahi dadi ByteArray.
var response = cellsInstance.CellsWorkbookPutWorkbookBackground(input_Excel, imageBytes, null);
Pungkasan, kita nelpon API kanggo nambah watermark menyang Excel lan nyimpen Workbook asil menyang panyimpenan maya.
File input Excel lan Gambar sing digunakake ing conto ing ndhuwur bisa diundhuh saka input.xls lan [Landscape.jpg](https://media.photographycourse.net/wp-content/uploads/ 2014/11/08164934/Landscape-Photography-steps.jpg) mungguh.
Mbusak Excel Watermark nggunakake C#
Kanthi Aspose.Cells Cloud, mbusak tandha banyu saka dokumen Excel cepet lan gampang, ngidini sampeyan nyelarasake alur kerja lan ngotomatisasi akeh tugas sing gegandhengan karo Excel. Tugas iki migunani yen sampeyan kudu nganyari utawa ngganti tandha banyu sing wis ana, utawa yen sampeyan pengin mbusak kabeh. Kanthi Aspose.Cells Cloud API, sampeyan bisa kanthi gampang mbusak watermarks saka kabeh lembar kerja Excel. API banjur bakal mbusak watermark saka lembar kerja sing ditemtokake, ninggalake dokumen liyane ora diganti.
// Kanggo conto lengkap lan file data, bukak
https://github.com/aspose-cells-cloud/aspose-cells-cloud-dotnet/
// Entuk kredensial klien saka https://dashboard.aspose.cloud/
string clientSecret = "4d84d5f6584160cbd91dba1fe145db14";
string clientID = "bb959721-5780-4be6-be35-ff5c3a6aa4a2";
// nggawe conto CellsApi nalika ngliwati ClientID lan ClientSecret
CellsApi cellsInstance = new CellsApi(clientID, clientSecret);
// Input buku kerja Excel kanthi tandha banyu ing drive lokal
string input_Excel = "input.xls";
try
{
// Waca buku kerja Excel lan upload menyang panyimpenan maya
cellsInstance.UploadFile(input_Excel, File.OpenRead(input_Excel));
// Telpon API kanggo mbusak tandha banyu saka kabeh lembar kerja Excel
var response = cellsInstance.CellsWorkbookDeleteWorkbookBackground(input_Excel, null);
// print pesen sukses yen concatenation sukses
if (response != null && response.Equals("OK"))
{
Console.WriteLine("Watermarks removed successfully from Excel !");
Console.ReadKey();
}
}
catch (Exception ex)
{
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
Ing cuplikan kode ing ndhuwur, baris kode ing ngisor iki tanggung jawab kanggo mbusak gambar watermark saka buku kerja Excel.
var response = cellsInstance.CellsWorkbookDeleteWorkbookBackground(input_Excel, null);
Setel Gambar Latar Excel nggunakake CURL Commands
Aspose.Cells Cloud nyedhiyakake REST API sing gampang lan gampang digunakake, ngidini sampeyan nggabungake fungsi watermarking dokumen Excel menyang alur kerja kanthi lancar. Salajengipun, kanthi bantuan printah cURL, kita bisa ngotomatisasi operasi iki lan nyederhanakake tugas sing gegandhengan karo Excel. Saiki, kanggo nambah watermark, kita kudu ngirim request cURL POST menyang Aspose.Cells Cloud API kanthi setelan watermark lan file dokumen Excel minangka parameter.
Nanging, pisanan kita kudu nginstal cURL ing sistem kita banjur ngasilake accessToken adhedhasar kredensial klien:
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Kapindho, gunakake printah ing ngisor iki kanggo ngunggah input Excel menyang panyimpenan awan:
curl -v "https://api.aspose.cloud/v3.0/cells/storage/file/{filePath}" \
-X PUT \
-F file=@{localFilePath} \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer {accessToken}"
Ganti
{filePath}
nganggo path sing arep disimpen file ing panyimpenan maya,{localFilePath}
karo path Excel ing sistem lokal sampeyan, lan{accessToken}
nganggo token akses Aspose Cloud. (digawe ing ndhuwur).
Pungkasan, tindakake printah ing ngisor iki kanggo nyisipake watermark ing buku kerja Excel online:
curl -v "https://api.aspose.cloud/v3.0/cells/{excelFile}/background" \
-X PUT \
-H "accept: multipart/form-data" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: multipart/form-data" \
-d "File":{"watermarkImage"}
Ganti
{excelFile}
karo jeneng input file Excel ing panyimpenan maya Ganti{accessToken}
karo token akses sing digawe ing ndhuwur Ganti{watermarkImage}
nganggo gambar raster sing kasedhiya ing drive lokal
- Sawise operasi sukses, Excel watermarked bakal disimpen ing panyimpenan maya padha.
Panutup
Sakabèhé, nambah lan mbusak tandha banyu ing dokumen Excel bisa mbantu nglindhungi data lan njaga integritas dokumen. Aspose.Cells Cloud nawakake solusi sing kuat kanggo ngrampungake tugas kasebut kanthi cara sing gampang lan gampang. Kanthi nggunakake Aspose.Cells Cloud API lan perintah cURL, sampeyan bisa kanthi gampang ngotomatisasi proses kasebut lan nggabungake menyang alur kerja sing wis ana. Kanthi fitur tambahan kayata konversi dokumen, format, lan manipulasi, Aspose.Cells Cloud minangka alat sing migunani kanggo ngatur dokumen Excel ing méga.
Pranala Migunani
Artikel sing Disaranake
Mangga bukak link ing ngisor iki kanggo mangerteni sing luwih lengkap babagan: